Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: runtime problem; elusive error

by perl-diddler (Chaplain)
on Sep 20, 2007 at 16:53 UTC ( [id://640182]=note: print w/replies, xml ) Need Help??


in reply to Re: runtime problem; elusive error
in thread runtime problem; elusive error

Looks like the "workaround" would be (removing the @Vals) line, as that hides the errormy $_debug_ops = (0 | DBG_RAND | DBG_KEYS |DBG_INFO); That puts in numeric context...sigh. Sometimes I'd like to be able to put a "numeric" or "string" in front a var to let it know what I want. The alternative is use something of the appropriate type (num or string), first, but that's not nearly so clear as being able to put in a "numeric" , like one does with "scalar", now.

Thanks for the heads up...I'd report it as a but, but not sure how they'd fix it -- though I sure don't know why it's returning "=28" (hex equiv to left paren).

It's interesting that the XS version is consistent (i.e. same constant).

Replies are listed 'Best First'.
Re^3: runtime problem; elusive error
by almut (Canon) on Sep 20, 2007 at 17:44 UTC
    though I sure don't know why it's returning "=28"

    That's the bitwise string-OR of the stringified decimal representations of the three values, i.e.

    "128" | "8" | "4"

    or, more eplicitly

    chr(ord('1') | ord('8') | ord('4')) . # '=' chr(ord('2') | ord('') | ord('') ) . # '2' chr(ord('8') | ord('') | ord('') ) # '8'
Re^3: runtime problem; elusive error
by ikegami (Patriarch) on Sep 20, 2007 at 19:16 UTC

    I'd like to be able to put a "numeric" or "string" in front a var to let it know what I want

    You can. They are spelled "0+" and "''." respectively.

    my $x = '8'; my $y = '16'; print((0+$x) | (0+$y), "\n"); # 24 print((''.$x) | (''.$y), "\n"); # 96

    Update: Oops, that doesn't quite answer your question. If the variable wasn't read-only, you could do the following:

    $x .= ''; # Stringify $x += 0; # Numerify

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://640182]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-24 04:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found