Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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?

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?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2016-10-26 21:20 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (349 votes). Check out past polls.