in reply to Re: Getting data from either ARGV or STDIN
in thread Getting data from either ARGV or STDIN
Just according to -X is -t defaulting to STDIN so you could spare a word.True, but I'd probably have to keep looking that up to remind myself what it's doing. I was actually thinking of spending another char and switching to !-p STDIN since that's a bit more self-documenting.
An alternative approach which seems cleaner to me could be to create an iterator which either implements:Excellent suggestion! It's both more succinct and understandable.
Thanks!my $iter = (@ARGV || -t STDIN) ? sub { shift @ARGV } : sub { <STDIN> } +; while (defined(my $in = $iter->())) { }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Getting data from either ARGV or STDIN
by LanX (Saint) on Mar 11, 2021 at 23:43 UTC | |
|
Re^3: Getting data from either ARGV or STDIN
by LanX (Saint) on Mar 11, 2021 at 23:30 UTC |