Is this a valid number?

Discussion in 'Perl Misc' started by AShrestha, Apr 23, 2004.

  1. AShrestha

    AShrestha Guest

    Hi,

    I am checking to see if an $a is valid number (could be 12 12. 12.0
    ..12). The logic I used was to check for only digits with no or one \.
    character. I am not able to get the right answer with this? Help
    appreciated

    regards,
    AS


    #!/usr/bin/perl

    $a= "11.2.";

    if ($a != /(\D+ & [^\.?])/) {
    print "$a it VALID\n";
    } else {
    print "INVALID number\n";
    }
     
    AShrestha, Apr 23, 2004
    #1
    1. Advertising

  2. A. Sinan Unur, Apr 23, 2004
    #2
    1. Advertising

  3. AShrestha

    Robin Guest

    "Purl Gurl" <> wrote in message
    news:...
    > Christian Winter wrote:
    >
    > > AShrestha wrote:

    >
    > (snipped)
    >
    > > > I am checking to see if an $a is valid number

    >
    > > "How do I determine whether a scalar is a number/whole/integer/float?"

    >
    > All of those methods listed in perl documentation
    > produce incorrect results. You will find numerous
    > articles in archives for this group addressing
    > this failure of those methods; none work correctly.
    >
    > http://www.purlgurl.net/~purlgurl/perl/numbers/parsenum.html
    >
    >
    > Purl Gurl


    are you serious?
    huh...
    (mailed and posted)
    -Robin
     
    Robin, Apr 25, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. makok
    Replies:
    1
    Views:
    6,899
    Anders Hellerup Madsen
    Feb 23, 2004
  2. hari
    Replies:
    6
    Views:
    7,026
    hamilton
    May 2, 2004
  3. Ole
    Replies:
    0
    Views:
    5,187
  4. Count Dracula

    Checking for valid number syntax

    Count Dracula, Dec 20, 2006, in forum: C Programming
    Replies:
    9
    Views:
    355
    Jorgen Grahn
    Dec 22, 2006
  5. Replies:
    6
    Views:
    95
    foo bar baz qux
    Nov 29, 2005
Loading...

Share This Page