in reply to Reading specific lines in a file

What about something really simple like that:
perl -ne 'print if 60..70;' file.txt

Replies are listed 'Best First'.
Re^2: Reading specific lines in a file
by gurpreetsingh13 (Scribe) on May 20, 2014 at 09:25 UTC
    That's good one.
    Correct me if I'm wrong. Hope this is using $_ and not $., since a while loop is roaming around the statement with perl -n .
    So what would be the expanded form of this statement?
      as pointed by ambrus in the chat $. come in place because of flip flop operator
      If either operand of scalar ".." is a constant expression, that operan +d is considered true if it is equal (== ) to the current input line n +umber (the $. variable).

      HtH
      L*
      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      It is using implicitly both $. and $_. A possible expanded form could be:
      perl -ne 'print $_ if $. >= 60 and $. <= 70' file.txt
      or, expanding further:
      perl -e 'while (<>) {print $_ if $. >= 60 and $. <= 70;}' file.txt