Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: <> oddity ?

by LanX (Chancellor)
on Mar 27, 2013 at 10:48 UTC ( #1025673=note: print w/replies, xml ) Need Help??


in reply to Re^2: <> oddity ?
in thread <> oddity ?

you're right

from perlop

       The null filehandle <> is special: it can be used to emulate the
       behavior of sed and awk.  Input from <> comes either from standard
       input, or from each file listed on the command line.  Here’s how it
       works: the first time <> is evaluated, the @ARGV array is checked, and
       if it is empty, $ARGV[0] is set to "-", which when opened gives you
       standard input.  The @ARGV array is then processed as a list of
       filenames.  The loop

while (<>) { ... # code for each line }

is equivalent to the following Perl-like pseudo code:

unshift(@ARGV, '-') unless @ARGV; while ($ARGV = shift) { open(ARGV, $ARGV); while (<ARGV>) { ... # code for each line } }

Cheers Rolf

( addicted to the Perl Programming Language)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025673]
help
Chatterbox?
[MidLifeXis]: Weird - my team is receiving a request for information barely related to a project we are on, asking for information already available to the user from a corporate data source, which happens to be the same source we would use.
[MidLifeXis]: It seems like the requester believes that we have some magic 8 ball source of info that he doesn't have access to.
[GotToBTru]: heh

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2017-01-20 18:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (176 votes). Check out past polls.