According to the open
pragma's documentation, you've already got the behavior you want:
The open
pragma serves as one of the interfaces to declare default "layers" (also known as "disciplines") for all I/O. Any two-argument open
, readpipe
(aka qx//
) and similar operators found within the lexical scope of this pragma will use the declared defaults. Even three-argument opens may be affected by this pragma when they don't specify IO layers in MODE.
The perlop documentation tells us that while (<>) { ... }
is equivalent to
unshift(@ARGV, '-') unless @ARGV;
while ($ARGV = shift) {
open(ARGV, $ARGV);
while (<ARGV>) {
... # code for each line
}
}