in reply to Question about Numbers, Strings & SPLIT
You need to escape '.' in the regular expression like this:
split /\./
'.' in a regular expression matches any single character, rather than the period character.
Please have a look through perlre.
Personally, I like to do:
If $fract isn't defined, it'll be evaluated as zero when used numerically.my ($whole,$fract) = ($hjd =~ /(\d+)(\.\d+)?/);
-David
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Question about Numbers, Strings & SPLIT
by kinnerc (Initiate) on Nov 29, 2007 at 04:49 UTC |
In Section
Seekers of Perl Wisdom