- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl: Command Line Arguments
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2003 10:08 AM
тАО01-21-2003 10:08 AM
Does anyone have an example of passing two or three command line arguments to a Perl script? I've searched the ITRC and found plenty examples of passing arguments to a Perl subroutine, but not to the Perl script itself. i.e. From a POSIX or Bourne shell script or directly from the crontab file.
It's probably indicative of how little I know about PERL. I've tried taking the "subroutine" examples and using them. But I can't get them to work.
Thanks,
Tom
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2003 10:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2003 10:24 AM
тАО01-21-2003 10:24 AM
Re: Perl: Command Line Arguments
http://members.shaw.ca/andrew-johnson/perl/archit/Oct00
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2003 12:12 PM
тАО01-21-2003 12:12 PM
Re: Perl: Command Line Arguments
A major difference with programming in C is that $ARGV[0] is the first argument, and not the program name. Perl has no $ARGC, but since $#ARGV is available as the last defined index in @ARGV, that should not prove to be a problem. Using @ARGV in scalar context
$argc = @ARGV;
or
print "I have ", scalar @ARGV, " arguments\n";
will return the number of arguments passed to the script. Look at $0 and/or $^X to see how the script was called.
Some options can be set to variables implicitely without using @ARGV. See 'man perltun' for the details of using -s. Another thing to be aware of is the way perl scans the hashbang line
#!/usr/bin/perl -ws
passes the -w and -s options to the script without you having to type them.
HTH. Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 04:23 AM
тАО01-22-2003 04:23 AM
Re: Perl: Command Line Arguments
Thanks! I knew I should be using the ARGV array, but I just couldn't get the syntax right.
Tom