Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: ls piped tpo perl -pe runs indefintely

by Anonymous Monk
on May 01, 2012 at 13:46 UTC ( [id://968253]=note: print w/replies, xml ) Need Help??


in reply to ls piped tpo perl -pe runs indefintely

shift keeps on reducing the number of elements in @ARGV in the second instance. Thus the while loop (via -n option) ends eventually. See perldoc perlrun, and Deparse ...

perl -MO=Deparse -ne ' map { print $_ , "\n" if ( -d $_ ) ; } @ARGV +' LINE: while (defined($_ = <ARGV>)) { map {print $_, "\n" if -d $_;} @ARGV; } -e syntax OK

Replies are listed 'Best First'.
Re^2: ls piped tpo perl -pe runs indefintely
by Anonymous Monk on May 01, 2012 at 13:59 UTC

    With respect to the first code instance, if I have (2 directories, 3 files) ...

    ../ ./ p/ q/ r s t

    ... then *nothing* is printed (perl 5.8.8, CentOS 6, zsh 4). If I remove the while loop (-n option), expected output is printed.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found