Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: grep flip flop (range operator)

by davido (Archbishop)
on Sep 13, 2012 at 07:23 UTC ( #993389=note: print w/replies, xml ) Need Help??


in reply to Re^2: grep flip flop (range operator)
in thread grep flip flop (range operator)

perl -E 'say "Yes!" if $. == 0;'

$. uninitialized if there's no file open for reading (undef). undef is false. In a numeric comparison, undef is promoted to zero (or conceptually better, zero is demoted to false, and undef is promoted to false). Consequently, 0 .. is true, and the flip flop flips.

If warnings were enabled you'd get one. :)


Dave

Replies are listed 'Best First'.
Re^4: grep flip flop (range operator)
by frozenwithjoy (Priest) on Sep 13, 2012 at 07:26 UTC
    Ah, yes.... and the reason it doesn't stop at Q is because it gets flipped right back on after Q. Apparently, my brain only works once per night. Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993389]
help
Chatterbox?
[1nickt]: Wow. I had heard about the chips on HP cartriddges but not that issue. I rejected HP's equivalent laptop becuase of build quality, very plasticky keyboard. And I believe HP is the champon of bloatware, too.
[stevieb]: Perhaps my experience with HP is a bit different as I always bought the highest end models through business.
[Corion]: 1nickt: At least the machines that $work is introducing to replace the Lenovo T60 here do not inspire confidence with me

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (20)
As of 2017-03-27 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.