http://www.perlmonks.org?node_id=1009764


in reply to Scalar Value Not Available To Subroutine

The code below prints the uid as expected from within the foreach loop. However, it will not print it in the subroutine. Why not and how can I fix it?

The reason is that the foreach loop localises $uid; but the subroutine mail closes over the variable declared above and outside the foreach loop, which is never initialised or assigned to.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong