Subject: RE: shift question
[EMAIL PROTECTED] wrote:
> Ok fantastic, I totally understand that, and if there were going to be
> more than one thing passed, just insert $par2 = shift; on the next
> line and then the second argument is in $par2, I assume.....right??
Yes.
You might also see it this way:
my ($par1, $par2) = @_;
The latter construct is not destructive of @_, while using shift() is. It
usually doesn't matter.
...
Please understand that you are passing a "list"...
So
&func($a, @b);
is different than
&func($a, $b);
Consider the example:
perl -e '$a=1;
@b=(2,3,4);
$c=5;]
&func($a,@b,$c);
sub func{
my ($a, @b,$c) = @_;
print "$a,$c,$b[3]\n";}'
Please note the absents of a value for $c in the sub above...
So...
&func($a,[EMAIL PROTECTED],$c);
perl -e '
$a=1;
@b=(2,3,4);
$c=5;
&func($a,[EMAIL PROTECTED],$c);
sub func{
my ($a, $b,$c) = @_;
print "$a,$c,$b->[2]\n";}'
jwm
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>