Just, according to -X is -t defaulting to STDIN. So you could spare a word.
2 other alternatives come to mind ...
An alternative approach which seems cleaner to me could be to create an iterator which either implements:
sub iter { shift @ARGV } °
or
sub iter {scalar <STDIN>} *
And use it in the loop
while ( ($id) = iter() ) { ... }
Another way could be to override readline (which is the iterator behind <> ) on demand to iterate over @ARGV.
Both ideas untested since I'm posting from mobile.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
°) Could be that you need
sub iter { shift @ARGV //()}
instead, I'm afraid shift will return undef if the array is exhausted.
*) updated scalar
In reply to Re: Getting data from either ARGV or STDIN
by LanX
in thread Getting data from either ARGV or STDIN
by sleet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |