Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: while(<>) in perl 5.22

by choroba (Cardinal)
on Nov 14, 2016 at 21:46 UTC ( [id://1175914]=note: print w/replies, xml ) Need Help??


in reply to while(<>) in perl 5.22

> somewhere between perl 5.x and 5.22

Interesting. The diamond operator <> is documented to behave this way for x=0.4 (I wasn't able to find older references easily).

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: while(<>) in perl 5.22
by BillKSmith (Monsignor) on Nov 14, 2016 at 23:04 UTC
    Neither result is consistent with my understanding of the 5.22 documentation.
    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 } }

    I would expect the open to fail silently.(There is no explicit test for errors.) The read on the unopened filehandle should return a false value. The loop would terminate without ever executing the print statement.

    Bill
      The documentation also says there's a difference, and you can easily see there is:
      ~ $ perl -e '1 while <>' non-existent-file Can't open non-existent-file: No such file or directory at -e line 1.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found