Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: one liner - open file and read

by NetWallah (Canon)
on Oct 07, 2010 at 18:07 UTC ( [id://864055]=note: print w/replies, xml ) Need Help??


in reply to Re: one liner - open file and read
in thread one liner - open file and read

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

Replies are listed 'Best First'.
Re^3: one liner - open file and read
by FunkyMonk (Chancellor) on Oct 07, 2010 at 18:23 UTC
    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

Re^3: one liner - open file and read
by eyepopslikeamosquito (Archbishop) on Oct 07, 2010 at 20:09 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-29 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found