Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: expanded "ls"

by nothingmuch (Priest)
on Aug 11, 2005 at 10:27 UTC ( [id://482897]=note: print w/replies, xml ) Need Help??


in reply to expanded "ls"

exec can be given arrays, so you don't need to quote arguments.

to get the pipe open behavior you can pipeopen ls, and then exec the pager:

open STDIN, "-|", ...; exec @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.

If you insist on quoting and concatenating there are cpan modules to do this more safely.

map { } in void context is silly:

$_ = qq{"$_"} for @ARGV;
To check if you have less, don't make assumptions based on the platforms. Instead:
use File::Which; my $pager = which("less") || which("more") || die "no pager";

Lastly, all of this could be completely superceded with a shell alias =)

-nuffin
zz zZ Z Z #!perl

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://482897]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-26 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found