Solved

shift(@ARGV) .....

Posted on 2003-12-06
5
3,328 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 60 total points
ID: 9892423
it represent an array variable.
in this context it is saying that ARGV is a array.
0
 
LVL 84

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now