in reply to Understanding why strict prevents a use of local
Either will do, but as others have said, avoid globals if you don't need them. ie:$::i # implicit, $main::i # explicit
works, but I would avoid creating a var if you don't need to. Eg:#!/usr/bin/perl -w use strict; my @array = qw(one two three); &one; sub one { local $::i; foreach $::i(@array) { &two; } } sub two { print "$::i\n"; }
#!/usr/bin/perl -w use strict; my @array = qw(one two three); one(); sub one { foreach (@array) { two($_); } } sub two { print "$_[0]\n"; }
TIMTOWTDI :)
cLive ;-)
|
|---|