I have a curious case of using "my" in a sub that I couldn't quite think it through.
I am just wondering if anyone can lend me some perl wisdom on this.
sub foo{ my $var = shift; my $href = shift; my @array = $href->{pass_in} if defined $href and exists $href->{pass_ +in}; push @array, $var; print "contents : @array"; } foo(1); foo(2);
output : contents : 1 contents : 1 2
So my question is that why @array is behaving like a static variable in C language here?
In reply to A curious case of of my() by fleetingflicker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |