Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Reliably parsing an integer

by haukex (Bishop)
on Jun 30, 2020 at 08:46 UTC ( #11118708=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub validate_int {
        my $str = shift;
    ...
            || sprintf("%0*s", length $max, $str) gt $max;
        return 0+$str;
    }
    
  2. or download this
    use warnings;
    use strict;
    ...
    ok exception { validate_int("999999999999999999999999999999999999") };
    
    done_testing;
    
  3. or download this
    #!/usr/bin/env perl
    use warnings;
    ...
    first   4544/s     --   -70%   -90%
    second 15386/s   239%     --   -67%
    third  46631/s   926%   203%     --
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2020-10-22 07:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (225 votes). Check out past polls.

    Notices?