CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
splitting

 



adp
newbie

Mar 13, 2001, 11:30 AM

Post #1 of 2 (470 views)
splitting Can't Post

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

Post #2 of 2 (469 views)
Re: splitting [In reply to] Can't Post

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

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives