in reply to one liner - open file and read

perl -lne '}{print $.' in.file

Replies are listed 'Best First'.
Re^2: one liner - open file and read
by NetWallah (Canon) on Oct 07, 2010 at 18:07 UTC
    That works, but I don't understand the syntax, or why it works.

    Please enlighten. -- Thanks.

         Syntactic sugar causes cancer of the semicolon.        --Alan Perlis

      perlrun says of -n:

      causes Perl to assume the following loop around your program, which makes it iterate over filename arguments somewhat like sed -n or awk:
      LINE: while (<>) { ... # your program goes here }
      So, perl replaces '...' with jwkrahn's '}{print $.'.

      Make sense now?

        Doh! - yes - thanks.

        No more END{..} in my one-liners.

        Cheers!

             Syntactic sugar causes cancer of the semicolon.        --Alan Perlis