in reply to How to use @ARGV

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:

$ perl -E 'say for @ARGV' file_1 file_2 file_1 file_2

You can assign it to another variable and use that:

$ perl -E 'my @x = @ARGV; say for @x' file_1 file_2 file_1 file_2

Be careful if your arguments (whether filenames or something else) start with a hyphen, e.g. the -file_1 and -file_2 you show:

$ perl -E 'say for @ARGV' -file_1 -file_2 -i used with no filenames on the command line, reading from STDIN.

They look like options (to both Perl and humans). Separate options and other (non-option) arguments with '--':

$ perl -E 'say for @ARGV' -- -file_1 -file_2 -file_1 -file_2

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