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.