That leads me to a question :-)
__CODE__ #!/usr/bin/perl use strict; use warnings;
my @numbers = ( '16#6.f7#e+2', '18.9', '2#01013#', '16e+2', ); my @valid = (0 .. 9, 'a' .. 'z');
for my $num (@numbers) { my ($base, $n, $exp); if ($num =~ /^(\d+)\#([^\#]*?)\#(?:e\+(\d+))?$/x) {
What particular use has the _x_ modifier in this example? I mean the hashes are escaped?
--manfred
($base, $n) = ($1, $2); $exp = defined $3 ? $3 : 1; } elsif ($num =~ /^(\d[\d._]*?)(?:e\+(\d+))?$/) { ($base, $n) = (10, $1); $exp = defined $2 ? $2 : 1; } next if not $n; my $invalid = '[^._'.join('',@valid[0..($base-1)]).']'; warn "invalid base $base number [$n] detected! ($invalid)\n" if $n =~ /$invalid/; print "got base $base, num $n, exp $exp\n"; } __END__
That should (more than) get you started!
HTH, Dave
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
-- http://glassdoc.org http://glassdoc.de
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
