Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Extract numbers in multiple bases

by MrNobo1024 (Hermit)
on Oct 15, 2001 at 02:38 UTC ( #118784=note: print w/ replies, xml ) Need Help??


in reply to Extract numbers in multiple bases

sub jcwren { my $num = shift; my($ok, $base, $value); if($num =~ m/^0x([\dA-Fa-f]+)$/s or $num =~ m/^([\dA-Fa-f]+)h$/s) { $ok = 1; $base = 16; $value = hex($1); } elsif($num =~ m/^([0-7]+)o$/s) { $ok = 1; $base = 8; $value = oct($1); } elsif($num =~ m/^([+-]?(?=\d|\.\d)\d*(?:\.\d*)?(?:[Ee](?:[+-]?\d+))? +)t?$/s) { $ok = 1; $base = 10; $value = 0 + $1; } else { $ok = 0; $base = 0; $value = 0; } return($ok, $base, $value); }


Comment on Re: Extract numbers in multiple bases
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2014-07-26 07:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls