Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^2: Any improvement over the code possible??

by Rohit Jain (Sexton)
on Sep 21, 2012 at 17:08 UTC ( #994950=note: print w/replies, xml ) Need Help??

in reply to Re: Any improvement over the code possible??
in thread Any improvement over the code possible??

Thanks for reply :)

I tried out this code.. but its not giving what I expected. Is it how it works??

#!/perl/bin use v5.14; use Scalar::Util; say &Scalar::Util::looks_like_number('2');

I haven't studied till packages and modules.. So, don't know exactly how to use them..

Replies are listed 'Best First'.
Re^3: Any improvement over the code possible??
by toolic (Bishop) on Sep 21, 2012 at 17:18 UTC
    its not giving what I expected
    You need to tell us what you expect it to do. Or read the doc I linked to:
    looks_like_number EXPR Returns true if perl thinks EXPR is a number.

    Super Search is another way to find answers and see code examples.

      If I write like this: -

      say looks_like_number '2'

      It should return false as I understand.. but its not printing anything

      Neither in the case I give there a number 2

        OK. got it worked by using the below code: -

        use Scalar::Util 'looks_like_number'; my $result = looks_like_number('abc');

        Do we have to import functions like this only? Else I have to do it for every function I import??

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994950]
[marto]: That reminds me, I made some notes somewhere with regard W::M::C, I'll get round to a PR when I've time to flesh it out
[Corion]: erix: But that makes for fun bug hunting. "What version of Chrome are you running?" "v62". "I also run v62 and it works on my machine". :-(
[Corion]: marto: Great, looking forward to the PR!
LanX wonders, do we have a rule against systematic down voting?
[erix]: we frown :)
[marto]: Does the command line arg --product-version@ help?
[LanX]: xD
[erix]: 'systematic' is going to be hard to define I think
[marto]: Err no @

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2017-12-12 20:19 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (335 votes). Check out past polls.