I think you are searching for anonymous subroutines and closures, but given that you indeed seem like a programming/Perl newbie, you shouldn't be venturing there and instead heed to the advice given in 1014512 above.
In reply to Re^3: foreach-loop-local var in sub
by Anonymous Monk
in thread foreach-loop-local var in sub
by warshall
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |