On Feb 3, david wright said: >I have seen Ex #1 "corrected" (as being more well written) to Ex #2. In >this case it is just being passed a $ but the data being passed was >irrelevant. (though not a ref) I still don't see why, i guess i don't >fully understand "shift". Any light shedder's appreciated, thanks : -)
I hope you haven't seen #1 written as #2. @a = @b; and @a = shift @b; are two VERY different things. The first one copies all the elements in @b to @a. The second one REMOVES THE FIRST ELEMENT from @b, and stores it in @a (as the only element). @b = (1 .. 3); @a = @b; print "<@a> <@b>\n"; # <1 2 3> <1 2 3> @a = shift @b; print "<@a> <@b>\n"; # <1> <2 3> Perhaps you've seen code like: my ($x) = @_; "corrected" to my $x = shift @_; That's not really "correct", since the second does something the first doesn't, but I hope you understand. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] 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. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]