$ perl -Mstrict -lne 'our $c += () = /foo/g; END { print $c }' abc foo foo foo 3 $ perl -Mstrict -lne 'my $c += () = /foo/g; END { print $c }' abc foo foo foo 1
Ok: always use strict. But not in one-liners...
So our is somewhat "exotic" in that it declares a package variable, but in a lexical scope.
Update: removed the statement modifiers that had inadvertently (yes!) slipped in as per Perl Mouse's remark
In reply to Re^3: difference between my and local
by blazar
in thread difference between my and local
by jeanluca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |