APM: shift question

Mike Stok mike at stok.co.uk
Sat Oct 19 18:53:05 CDT 2002


On Sat, 19 Oct 2002, Goldilox wrote:

> How come I can go
> 
> $x=shift @array;
> 
> and $x is equal to the first array element, but
> 
> shift @array;
> 
> doesn't put the first element to $_?

Because shift doesn't do that - the only defaults shift has are the arrays 
it operates on - @_ or @ARGV.

> I tried printing $_:
> 
> #!/usr/bin/perl -w
> use CGI;
> $cg=new CGI;
> print $cg->header;
> @directories = qw(01Jan 02Feb 03Mar 04Apr 05May 06Jun 07Jul 08Aug 09Sep 10Oct
> 11Nov 12Dec);
> print "Here ", at directories,"<br>";
> shift @directories;
> print "Here is \$_: $_";
> print $_;
> 
> and it is empty. Any hints?

Apart from

  $_ = shift @directories;

Hope this helps,

Mike

-- 
mike at stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       | GPG PGP Key      1024D/059913DA 
mike at exegenix.com                  | Fingerprint      0570 71CD 6790 7C28 3D60
http://www.exegenix.com/           |                  75D2 9EC4 C1C0 0599 13DA




More information about the Austin mailing list