kinnerc has asked for the wisdom of the Perl Monks concerning the following question:
I can't stand when I THINK things should work, and then not only don't they, but they give absolutely no indication at to why they are not doing what they should be doing.
What I want to do is input a real number and then split it between the left part of the decimal point and the right part of the decimal point. Now its my understanding that there is no difference in Perl between numbers and strings so I can't for the life of me understand why this doesn't work.
Code:
$hjd = 25445.3382; @fields = split /./, $hjd; print "$fields[1]\n"; # I expect to get '3382' I get a newline print "$fields[0]\n"; # I expect to get '25445' I get a newline
There may be better ways to do what I want to do. I understand that. But I have no idea why what I have coded above does not work.
Very frustrating, unfortunately.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question about Numbers, Strings & SPLIT
by erroneousBollock (Curate) on Nov 29, 2007 at 04:38 UTC | |
by kinnerc (Initiate) on Nov 29, 2007 at 04:49 UTC |