in reply to Re: Count number of lines in a text file
in thread Count number of lines in a text file

Very tricky. So because of the }, the continue { print $_; } block is no longer attached to the loop, but to the {$_=$.} bare block. I never knew this trick with -p. (I knew about -ne '...}{...' but not what it did with -p.)

Replies are listed 'Best First'.
Re^3: Count number of lines in a text file
by QM (Parson) on Mar 28, 2006 at 15:07 UTC
    Yes. But -p and -n only differ by the continue/print. Compare -p:
    > perl -MO=Deparse -pe"#stuff#" LINE: while (defined($_ = <ARGV>)) { (); } continue { print $_; }
    to -n:
    > perl -MO=Deparse -ne"#stuff#" LINE: while (defined($_ = <ARGV>)) { (); }

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of