APM: shift question

Goldilox Goldilox at teachnet.edb.utexas.edu
Sat Oct 19 23:52:48 CDT 2002


Actually, let me follow up with another question. Please forgive me if I'm
sounding too programatically naive.

I had actually read the documentation that shift defaults to @ARGV, so I had
tried seeing what was in the @ARGV array or even in $ARGV[0] and I still came
up with nothing. So I thought I was totally misunderstanding things. Then I
found references on the web that said the @ARG array and $_ were the same
thing, and so since $ARGV[0] didn't show me an output and $ARG[0] didn't show
me an output, and it had specifically stated that really @ARGV is only where
shift sends elements inside a subroutine, I thought it must be $_ that gets the
element shaved off the array by shift outside a subroutine. But now looking at
perldoc perlvar, there is no reference to @ARG, and I also now have tried $_[0]
and @_ trying to find this missing array element. Now, I'm not trying to defend
anything erroneous I might have read on the web, but I'm still confused by the
default variable when I place the shift command outside of a subroutine. In my
script, how would I print out the element shaved off by

shift @directories

?
(I hope I'm not beating a dead horse, I'm just still confused)

so instead of

print "Here is \$_: $_";

what should replace $_?

#!/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 $_;




More information about the Austin mailing list