Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by toolic (Chancellor)
on Sep 21, 2012 at 17:18 UTC ( #994952=note: print w/ replies, xml ) Need Help??


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

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.


Comment on Re^3: Any improvement over the code possible??
Download Code
Re^4: Any improvement over the code possible??
by Rohit Jain (Sexton) on Sep 21, 2012 at 17:23 UTC

    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??

        Different modules have different requirements, which are usually in the docs:
        By default Scalar::Util does not export any subroutines.

        So, for this module, you must import explicitly. See also perldoc -f use

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-08-23 18:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls