Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Extract numbers in multiple bases

by MrNobo1024 (Hermit)
on Oct 15, 2001 at 02:38 UTC ( [id://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); }

Log In?
Username:
Password:

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

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

    No recent polls found