Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Bug or Feature?

by Sec (Scribe)
on Feb 22, 2006 at 14:17 UTC ( #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?

Comment on Bug or Feature?
Download Code
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
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? | Other CB clients
Other Users?
Others examining the Monastery: (16)
As of 2015-07-28 15:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (257 votes), past polls