Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

shift(@ARGV) .....

Posted on 2003-12-06
5
Medium Priority
?
3,376 Views
Last Modified: 2006-11-17
To Experts,

   I have two perl programs, which output the same results.
--------------------------------------
#!/usr/bin/perl -w
use strict ;

my $dir ;
$dir = shift(@ARGV) || "/tmp" ; # line01..Q1
print $dir; print "\n" ;
--------------------------------------
#!/usr/bin/perl -w
use strict ;

my $dir1 ;
$dir1 = $ARGV[0] || "/tmp" ;
print $dir1; print "\n" ;
-------------------------------------
Q1. However, I do not understand what does it mean by "@ARGV" and "shift" in line01. Could anyone please explain it to me ?

Thanks !!!

meow.
0
Comment
Question by:meow00
  • 3
5 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9890198
ARGV is an array which stores values from stdin.
shift Remove the first element of an array, and return it.
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9890205
in first case,
shift takes the first value from array ARGV ie 0 and prints it.

in second case, u are not using shift and asking directly the first element of ARGV array and printing it.
thats why getting the same result.
0
 
LVL 1

Author Comment

by:meow00
ID: 9892417
Thanks, just have one more question :
what does "@" mean here ? Thanks a lot !!!

meow.
0
 
LVL 24

Accepted Solution

by:
shivsa earned 240 total points
ID: 9892423
it represent an array variable.
in this context it is saying that ARGV is a array.
0
 
LVL 85

Expert Comment

by:ozo
ID: 9893422
See
perldoc perldata
and
perldoc -f shift
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question