Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Question about Numbers, Strings & SPLIT

by erroneousBollock (Curate)
on Nov 29, 2007 at 04:38 UTC ( #653770=note: print w/replies, xml ) Need Help??

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:

my ($whole,$fract) = ($hjd =~ /(\d+)(\.\d+)?/);
If $fract isn't defined, it'll be evaluated as zero when used numerically.


Replies are listed 'Best First'.
Re^2: Question about Numbers, Strings & SPLIT
by kinnerc (Initiate) on Nov 29, 2007 at 04:49 UTC

    Bingo! You're a sanity saver! "." is a metacharacter! Of course! One blasted simple thing!

    THANK YOU!!!

    Doc Kinne

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2016-10-20 21:56 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (283 votes). Check out past polls.