in reply to How to use @ARGV

Hello chaney123,

It seems the fellow Monks have provided you with plenty of examples and tutorials. I would like to add something minor here.

My personal (favorite) way of handling @ARGV when you need to read files (but not only for that) I prefer to use it like this:

#!usr/bin/perl use strict; use warnings; while (<>) { print "$.\t$_"; # updating $. $.\t$_ } continue { close ARGV if eof; }

Depending upon the case of course but I tend to prefer to use it like this. It does not mean that it always the best solution, but it depends upon your task. You can read more about that here eof and also similar question with code samples on how to open a file and parse the data open and read text file.

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: How to use @ARGV
by BillKSmith (Monsignor) on Aug 29, 2017 at 20:25 UTC
    Also in the "I/O Operators" section of perlop. "The null filehandle <> is special..."
    Bill