in reply to Passing arguments in a subroutine
Note that, interestingly enough, the way you are invoking your function will actually pass arguments to the function and, simultaneously, create (masking) lexical variables within the scope of the function invocation, although why you would want to do this is beyond me (unless you're trying to drive your maintainer absolutely bonkers). Where did you come up with this approach?
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump=pp -le "sub S { print qq{in S: args }, pp \@_; } ;; S(my $x = 'foo', my $y = 'bar'); print qq{outside S: \$x == $x, \$y == $y}; ;; sub S (); " Prototype mismatch: sub main::S: none vs () at -e line 1. in S: args ["foo", "bar"] outside S: $x == foo, $y == bar
Update: Changed code example to include effect of late, prototyped subroutine declaration.
Update 2: Oh, and BTW: Don't use Prototypes unless you're absolutely sure what they do. I.e., don't use prototypes. See Far More than Everything You've Ever Wanted to Know about Prototypes in Perl -- by Tom Christiansen.
Give a man a fish: <%-(-(-(-<
|
|---|