Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Bug or Feature?

by Sec (Monk)
on Feb 22, 2006 at 14:17 UTC ( [id://531968]=perlmeditation: print w/replies, xml ) Need Help??

While debugging some code, I stumbled upon an interesting tidbit:
$b=chop($a="128"); print $b!= ($a & $b) ?"Just another ":"Perl hacker!\n"; print $b!= ($a & $b) ?"Just another ":"Perl hacker!\n";
I since figured out why it happens. Can you?

Replies are listed 'Best First'.
Re: Bug or Feature?
by blokhead (Monsignor) on Feb 22, 2006 at 15:07 UTC
Re: Bug or Feature?
by Aristotle (Chancellor) on Feb 22, 2006 at 16:03 UTC

    A bit of both. This is an interaction between bitwise integer ops vs bitwise string ops and how strings and numbers are autoconverted to each other and how the respective string/integer values are cached separately within a single scalar (cf. Scalar::Util::dualvar).

    Makeshifts last the longest.

Re: Bug or Feature?
by sh1tn (Priest) on Feb 23, 2006 at 01:15 UTC
    Or maybe just:
    print$_=$_&1?"Perl hacker!":"Just another ",$_?"Perl hacker!":"Just an +other "


Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://531968]
Approved by blokhead
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-23 23:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found