Use the \s+ to match one or more whitespace characters, but includes more than just the SPACE ascii value, the CR/LF characters, for instance.
 
@words = split( /\s+/, $line );
 
You might want to look at the Text::ParseWords module, as is handles many complex situations, like embedded quotes.
 
--Matt
-----Original Message-----
From: Nasir Kamal [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 18, 2002 9:26 AM
To: [EMAIL PROTECTED]
Subject: split function help ????

Split function in PERL.....
i want to split a sentence into words, i m using the following syntax:
 
split(/ /,$line)     #### note that I have given one space in between two slashes:
 
however in $line sentence there are often more than one spaces, like 2 spaces or 3 spaces.... i want split function to consider 2 or 3 spaces like 1 space (that is it should not matter how many spaces are there, consider it one only space)......
 
how ???
 
thanks in advance,
Nasir
 

Reply via email to