Home: Perl Programming Help: Beginner:
splitting



adp
newbie

Mar 13, 2001, 11:30 AM


Views: 1124
splitting

i have an entry in an array that i would like to split.
{the entry is 1.42 }
i would like to be able to isolate the 1 and the 42 into 2 fields.
why doesn't this work?:
@fields = split(/./, $numbers[1]);



japhy
Enthusiast

Mar 13, 2001, 11:50 AM


Views: 1123
Re: splitting

Because . is a special regex character. You'll need to backslash it to make it match a literal period.


Code
($dec, $frac) = split /\./, $number;

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author