There's more than one way to do things | |
PerlMonks |
Re: How to use @ARGVby kcott (Archbishop) |
on Aug 29, 2017 at 05:21 UTC ( [id://1198242]=note: print w/replies, xml ) | Need Help?? |
G'day chaney123, Welcome to the Monastery. @ARGV is a special variable (see perlvar). You'll find documentation about @ARGV, along with other variables containing 'ARGV', in the "Variables related to filehandles" section. You can use it directly in your code:
You can assign it to another variable and use that:
Be careful if your arguments (whether filenames or something else) start with a hyphen, e.g. the -file_1 and -file_2 you show:
They look like options (to both Perl and humans). Separate options and other (non-option) arguments with '--':
If your command line arguments are options, instead of trying to process them yourself, use one of the core modules. Getopt::Long is what I use. There's also Getopt::Std: I don't use that one so I can't really comment on it. — Ken
In Section
Seekers of Perl Wisdom
|
|