in reply to Usage of Shift function in PERL

It's working alright, you're changing the value of @ARGV, but you're not doing anything with the value it returns.

You seem to be expecting it'll put its return value into $_ when in void context, but it doesn't. I can't even think of any built-in function that does that, for the moment, though split clobbers up @_ in scalar and void context — and that usage is deprecated. Using $_ as a default argument: yes; as a return value: no.

Try:

$_ = shift @ARGV; print; # This does use $_ by default

Replies are listed 'Best First'.
Re: Usage of Shift function in PERL
by Abigail-II (Bishop) on May 03, 2004 at 11:45 UTC
    Well, there's while in combination with the diamond operator. Although that's technically boolean context - and it's special cased anyway.

    Abigail