Solved

shift(@ARGV) .....

Posted on 2003-12-06
5
3,356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
Six Sigma Control Plans

623 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