Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass parameter to a program ???

Status
Not open for further replies.

mackiew

Programmer
Joined
Sep 15, 2000
Messages
18
Location
UY
Hello !
I have a perl program called myPerlProgram.
I want pass a parameter myParameter (scalar) to it as:

comandLine> myPerlProgram myParameter <Enter>

What code must I include in myPerlProgram to catch myParameter into the program?

How I do it??

Thanks !
 
hi mac,
[tt]
my $arg = shift or die &quot;No argument specified\n&quot;;
print &quot;Argument was $arg\n&quot;;
[/tt]


Mike
michael.j.lacey@ntlworld.com
 
all arguments passed to a program are stored in the
@ARGV array.

shift is a great way to get an argument, but, if you are working with multiple arguments, its nice to know that they're in @ARGV.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top