Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Angle operator [updated]

by jo37 (Hermit)
on Oct 20, 2021 at 16:58 UTC ( #11137812=note: print w/replies, xml ) Need Help??


in reply to Re: Angle operator
in thread Angle operator

At first sight this behaviour looks very strange. If there was any data available via <>, the command x <> would consume all of it and the loop would not be entered. I've played a bit with this setup and are able to reproduce such a thing. If <> is exhausted and the final returned undef is ignored, the next call to <> will read from STDIN, even if file names were provided via @ARGV.

This behaviour is documented in I/O Operators.

I guess there is some part in the script that ignores an undef return from <> or evaluates it in list context before the loop in question. And there are named files in addition to data from STDIN.

Update:

...the loop would not be entered.

This it not true and is not what I wanted to say. The loop is entered, but it will wait for input from STDIN.

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Replies are listed 'Best First'.
Re^3: Angle operator [updated]
by jerryhone (Sexton) on Oct 20, 2021 at 20:24 UTC
    Thanks for the link. I think I've read it before but so many years ago, I'd forgotten how magical (or maybe devilish!) diamond operators are. I'm away from my desk right now so will take another look in the morning, but it is true that the script has ARGV processing including composite arguments and a STDIN redirection(<) on the command line, so there's every possibility that there's some quirkiness that the Perl versions have handled differently. This is the only viable patch I can come up with...
    while ( <> ) { next if (length($_) == 0); . .

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2022-01-20 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (57 votes). Check out past polls.

    Notices?