Command line arguments. 
Author Message
 Command line arguments.

I'm writing some Perl programs to run straight from the Linux shell (i.e.
they start with #!/usr/bin/perl and are executable) and I want to pass
command line arguments to them.

Is there a way to determine within the program how many arguments have been
passed?

Is there anything like shift (in Bash scripts) to pick the arguments off
one at a time?

Thanks
Adam



Fri, 07 May 2004 01:13:14 GMT  
 Command line arguments.
Adam,

Did you read any documentation?



        stuff;
        }

You can also pop or shift them out -- depending on which end of the args
you want to start at.

havoc

Quote:

> I'm writing some Perl programs to run straight from the Linux shell (i.e.
> they start with #!/usr/bin/perl and are executable) and I want to pass
> command line arguments to them.

> Is there a way to determine within the program how many arguments have been
> passed?

> Is there anything like shift (in Bash scripts) to pick the arguments off
> one at a time?

> Thanks
> Adam

______________________________________________________________________________
Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net


Fri, 07 May 2004 08:54:20 GMT  
 Command line arguments.
Yes and yes.


runtime.  You can use shift() and you can actually use it in more places
than just the command line arguments.  If you wanting to actually do any
checking of the arguments I suggest you use the Getopt packages Getopt::Std,
Getopt::Long, etc etc.

perldoc Getopt::Std
perldoc perlvar

--
- Jim

-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
http://www.perlmonks.org/index.pl?node_id=67861&lastnode_id=67861



Fri, 07 May 2004 07:57:23 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help! with command line arguments

2. Simple reordering of command line arguments.

3. Command line arguments?

4. Passing form values back to a script as command line arguments

5. How to set varible from command line argument??

6. patch1 for wafeperl 0.2 to allow xt command line argument processing

7. Modification of command line arguments

8. Where are command line arguments described?

9. Command line arguments

10. escape characters within command line arguments

11. command line argument

12. Newbie ?: @ARGV not getting command line arguments

 

 
Powered by phpBB® Forum Software