in reply to Re^2: Reading multiple files one line at a time from arguments
in thread Reading multiple files one line at a time from arguments
++! I knew I was forgetting something useful.
In that case:
die "Usage: mytest filename [filename [...]]\n" unless @ARGV; while ( <> ) { print "$ARGV($.): $_" } continue { close ARGV if eof }
That will print current file, current line number, and then the line. The continue clause serves to reset the line number before moving on to the next file. Otherwise $. would just keep counting upward, giving a total for all files.
I have no idea why I indented it that way. Just looking for symmetry or something, I guess.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Reading multiple files one line at a time from arguments
by choroba (Cardinal) on Jun 19, 2014 at 08:18 UTC | |
by davido (Cardinal) on Jun 19, 2014 at 08:40 UTC |