Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Bring back the smartmatch operator (but with sane semantics this time)!

by flowdy (Scribe)
on Jun 15, 2014 at 12:13 UTC ( #1089939=note: print w/replies, xml ) Need Help??


in reply to Re^3: Bring back the smartmatch operator (but with sane semantics this time)!
in thread Bring back the smartmatch operator (but with sane semantics this time)!

When do you consider something a number?

I personally would just go for a technical, non-heuristic approach:

  • Numbers: 42, $scalar+0, $scalar having a defined numeric context slot
  • Non-numbers: 'quoted string', $scalar
  • Comment on Re^4: Bring back the smartmatch operator (but with sane semantics this time)!

Replies are listed 'Best First'.
Re^5: Bring back the smartmatch operator (but with sane semantics this time)!
by moritz (Cardinal) on Jun 16, 2014 at 19:47 UTC
    use 5.014; use strict; use Devel::Peek; my $x = 'not a number'; say 0 + $x; Dump $x; __END__ 0 SV = PVNV(0x1b87050) at 0x1ba83b8 REFCNT = 1 FLAGS = (PADMY,POK,IsCOW,pIOK,pNOK,pPOK) IV = 0 NV = 0 PV = 0x1bafe30 "not a number"\0 CUR = 12 LEN = 14 COW_REFCNT = 1

    By your definition, smart-matching against $x would do a numeric comparision, because it has a numeric slot. There's your WTF right away.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1089939]
help
Chatterbox?
[Tanktalus]: Lady_Aleena: yeah, I can reproduce your issue, it's confusing alright :)
[Tanktalus]: I'm sure it'll make perfect sense once we figure it out :)
[Lady_Aleena]: marioroy, not a quoting error. I can't run it on the command line. It is when I put it in qx() where it falls apart.
Discipulus hired to use Perl in Eataly? haired maybe
[choroba]: We're hiring
[Discipulus]: wow praha!
[Tanktalus]: choroba: do I have to move? :)
Discipulus has too much roots in a 2770 yo town
[marioroy]: I want a job after completing MCE in about a week. But feel that I've moved to the wrong place.
[choroba]: I fear so. We have offices in Prague, Brno, Saigon and San Francisco.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2017-04-23 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.