[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Mystical @_ in subs



> sub swap { @_ = @_[1,0] } # doesn't work, but
> sub swap { @_[1,0] = @_ } # does.

Well of course.  Each element of @_ is secretly the ACTUAL value passed,
so modifying the values of @_ themselves modifies the values passed.  But
setting

  @_ = LIST;

is not the same as

  @_[0..$#_] = LIST;

Need this be written as a special case?

-- 
  MIDN 4/C PINYAN, USNR, NROTCURPI     http://www.pobox.com/~japhy/
  jeff pinyan: japhy@pobox.com     perl stuff: japhy+perl@pobox.com
  "The Art of Perl"               http://www.pobox.com/~japhy/book/      
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/
  PerlMonth - An Online Perl Magazine     http://www.perlmonth.com/


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe