develooper Front page | perl.beginners | Postings from February 2002

Re: Arrays 1x3 or 3x1 - The real questions

Thread Previous | Thread Next
From:
Jeff 'japhy' Pinyan
Date:
February 12, 2002 14:06
Subject:
Re: Arrays 1x3 or 3x1 - The real questions
Message ID:
Pine.GSO.4.21.0202121703560.11490-100000@crusoe.crusoe.net
On Feb 12, Steven M. Klass said:

>&Somefunction($var1, \@arry)
>
>sub SomeFunction {
>	my $var = $_[0];    # XXX you were missing a ; here
>	my $array = shift;

Uh, $array and $var have the same value now.  shift() removes the first
element from an array (defaulting to @_) and returns it.  The first
element of @_ is $_[0], which is $var1.

Saying

  my $var = $_[0];

is not the same as

  my $var = shift;

The first one does NOT remove the element from @_; the second one DOES.

-- 
Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About