in reply to expanded "ls"
to get the pipe open behavior you can pipeopen ls, and then exec the pager:
FYI, that is how the shells do it: they create the pipeline descriptors, fork off children for the processes, dup the filedescriptors to stdin/stdout as appropriate, and then exec the subproccesses.open STDIN, "-|", ...; exec @pager;
If you insist on quoting and concatenating there are cpan modules to do this more safely.
map { } in void context is silly:
To check if you have less, don't make assumptions based on the platforms. Instead:$_ = qq{"$_"} for @ARGV;
use File::Which; my $pager = which("less") || which("more") || die "no pager";
Lastly, all of this could be completely superceded with a shell alias =)
|
---|