P0w3rK!d has asked for the wisdom of the Perl Monks concerning the following question:
Given this piece of code:
..it works. However, given this piece of code:# a=463.3742.23 # b=99 sub getFoo{ my $a; my $b; my $strFoo; ($a,$b) = @_; $strFoo .= $a; $strFoo .= "_"; $strFoo .= $b; $strFoo .= "_testme"; $strFoo .= ".xml"; return $strFoo; } Result: $strFoo=463.3742.23_99_testme.xml
Why is this intermittent behavior occurring?# single value passed in = 463.3742.23 sub getFoo{ my $strFoo = @_; $strFoo .= "_testme"; $strFoo .= ".xml"; return $strFoo; } Result: $strFoo=463.3742.23_testme.xml *or* $strFoo=1_testme.xml
Either:
Note: Running ActiveState Perl 5.8 build 508
-P0w3rK!d
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: shift vs. @_ (where @_ evaluates to 1)
by pfaut (Priest) on May 09, 2003 at 17:58 UTC | |
by P0w3rK!d (Pilgrim) on May 09, 2003 at 18:47 UTC | |
|
Re: shift vs. @_ (where @_ evaluates to 1)
by dws (Chancellor) on May 09, 2003 at 18:12 UTC | |
by P0w3rK!d (Pilgrim) on May 09, 2003 at 18:46 UTC | |
|
Re: shift vs. @_ (where @_ evaluates to 1)
by Zaxo (Archbishop) on May 10, 2003 at 01:42 UTC |