Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Reliably parsing an integer

by haukex (Archbishop)
on Jun 30, 2020 at 08:46 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11118708]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found