Solved

shift(@ARGV) .....

Posted on 2003-12-06
5
3,315 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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 …
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

18 Experts available now in Live!

Get 1:1 Help Now