BASH: Global variables aren't updateable in a function only when that function is piped (simple example)
A pipe creates a subshell. It's said in the bash manual that subshells cannot modify the environment of their parents. See these links:
http://www.gnu.org/software/bash/manual/bashref.html#Pipelines
http://wiki.bash-hackers.org/scripting/processtree#actions_that_create_a_subshell