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

Re: vexed by the hex!

by Eily (Monsignor)
on Jan 13, 2017 at 14:07 UTC ( #1179507=note: print w/replies, xml ) Need Help??


in reply to vexed by the hex!

The eq operator works on strings, and thus turns its two operands into strings before doing anything else. This is called "string context" and also happen when you print something:

# here EXPR is in string context print EXPR;
0x11 is a number (17), not a string, so perl turns it into a string the way it usually does. You can try this: print 0x11; and you'll see that ($status eq 0x11) is actually ($status eq "17"). If you want to do a character comparison, you can do: $status eq chr(17)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1179507]
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 2019-11-15 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (80 votes). Check out past polls.

    Notices?