command line commands passed to perl script?

Hi all,
Sorry, should have added this to my last email. Does
anyone know how to pass values to a perl script
through the command line? Do you use param as in CGI
scripting/
I want a user to be able to specify certain parameters
for the perl script (in case they want to run an
overnight scheduler on it).
Eg. testscript.pl /? gives you help or testscript /a
gives you another capability...
Ben
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
0
crane_ba
12/9/2003 4:22:46 PM
📁 perl.beginners
📃 29388 articles.
⭐ 4 followers.

💬 5 Replies
👁️‍🗨️ 777 Views


Nameofperlscript command1 command2 command3
Params stored in global variable @ARGV

> -----Original Message-----
> From: Ben Crane [mailto:crane_ba@yahoo.com] 
> Sent: Tuesday, December 09, 2003 11:23 AM
> To: beginners@perl.org
> Subject: command line commands passed to perl script?
> 
> 
> Hi all,
> 
> Sorry, should have added this to my last email. Does
> anyone know how to pass values to a perl script
> through the command line? Do you use param as in CGI
> scripting/
> 
> I want a user to be able to specify certain parameters
> for the perl script (in case they want to run an
> overnight scheduler on it).
> 
> Eg. testscript.pl /? gives you help or testscript /a
> gives you another capability...
> 
> Ben
> 
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing. 
http://photos.yahoo.com/
-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>

0
pkraus
12/9/2003 4:38:32 PM
You should use this: testscript.pl  blah
where blah is the value to pass.

Ben Crane wrote:
>Hi all,
>
>Sorry, should have added this to my last email. Does
>anyone know how to pass values to a perl script
>through the command line? Do you use param as in CGI
>scripting/
>
>I want a user to be able to specify certain parameters
>for the perl script (in case they want to run an
>overnight scheduler on it).
>
>Eg. testscript.pl /? gives you help or testscript /a
>gives you another capability...
>
>Ben
>
>__________________________________
>Do you Yahoo!?
>New Yahoo! Photos - easier uploading and sharing.
>http://photos.yahoo.com/
>
>  
>

0
mygrps
12/9/2003 5:15:23 PM
On Dec 9, 2003, at 8:38 AM, Paul Kraus wrote:
[..]
> Nameofperlscript command1 command2 command3
>
> Params stored in global variable @ARGV

ben,
the alternative of course is to look into
        perldoc Getopt::Long
where you can do many majical voodoo with...
Oh dear, just found my old DOG about getopt
<http://www.wetware.com/drieux/pbl/Sys/NextStuff/getOptStd.txt>
oye is that old... and yes it was built to have
code start code that does the GetOpt stuff...

ciao
drieux
---
0
drieux
12/9/2003 6:01:22 PM
Ben Crane wrote:
> 
> Hi all,
Hello,
> Sorry, should have added this to my last email. Does
> anyone know how to pass values to a perl script
> through the command line? Do you use param as in CGI
> scripting/
> 
> I want a user to be able to specify certain parameters
> for the perl script (in case they want to run an
> overnight scheduler on it).
> 
> Eg. testscript.pl /? gives you help or testscript /a
> gives you another capability...
If you want to use the DOS command line switch (/) you could write your
own parser for the @ARGV array however Perl provides the Getopt::Std and
Getopt::Long modules which use the more standard '-' and '--' for
processing command line switches.
perldoc Getopt::Std
perldoc Getopt::Long

John
-- 
use Perl;
program
fulfillment
0
krahnj
12/9/2003 10:11:16 PM
=20
IMHO, parsing command-line options sounds a lot easier than it is.
Definitely use the modules unless you have a good reason for not doing
so.  The author(s) of the module have probably already dealt with the
forehead-slappers that might not be obvious right off the bat, and it
will save you a lot of time down the road.  Save your brainpower for the
more important parts of your program rather than reinventing this
particular wheel.  Again, it's just my opinion...
0
tjohnson
12/9/2003 10:18:56 PM
Reply: