Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] Test for Number or String

Expand Messages
  • Charles K. Clarkson
    Mike Dillinger queried: [snip] ... use POSIX; my $test = 7000_000_003; print isdigit( $test ) ? numeric n : string n ; HTH, Charles
    Message 1 of 3 , May 2, 2002
      "Mike Dillinger" <miked@...> queried:

      [snip]
      : Is there an easier way to test for numeric stuff?
      : I know C has isnum or isdigit or something like that,
      : and it would be cool if PERL had a function like that
      : rather than doing a regexp test. I'm also open to
      : suggestions on how to test for numeric responses
      : that you might have.

      use POSIX;
      my $test = 7000_000_003;
      print isdigit( $test ) ? "numeric\n" : "string\n";


      HTH,

      Charles K. Clarkson
      --
      Head Bottle Washer,
      Clarkson Energy Homes, Inc.

      CJ Web Work - Domains for Real Estate Investors.
      E Pluribus Unum -- One from many.
    • Jeff 'japhy' Pinyan
      ... C does it differently because C is not Perl. Try perldoc -q integer and see what the FAQ tells you. You re not too far off. -- Jeff japhy Pinyan
      Message 2 of 3 , May 2, 2002
        On May 2, Mike Dillinger said:

        >Is there an easier way to test for numeric stuff? I know C has isnum or
        >isdigit or something like that, and it would be cool if PERL had a
        >function like that rather than doing a regexp test. I'm also open to
        >suggestions on how to test for numeric responses that you might have.

        C does it differently because C is not Perl.

        Try 'perldoc -q integer' and see what the FAQ tells you. You're not too
        far off.

        --
        Jeff "japhy" Pinyan japhy@... http://www.pobox.com/~japhy/
        RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
        ** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
        <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
        [ I'm looking for programming work. If you like my work, let me know. ]
      Your message has been successfully submitted and would be delivered to recipients shortly.