Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Bug or Feature?

by Sec (Monk)
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-03-17 21:11 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (226 votes). Check out past polls.