From: <[EMAIL PROTECTED]>
> In my script i would like to split a single scalar containing a random
> passage of text into a list, which holds the words of the text.
> 
> For my case however i would like to have also linefeeds treated as
> "words", because i want to preserve them (in order not to mix up the
> layout of the text when writing the list of words to an outfile).
> Consequently i would think that using like in the example above
> 
>  \s = [\x20\f\t\r\n]
> 
>  minus
> 
>  \n
> 
>  would preserve my linefeeds. However when using this regexp i get
>  unwanted results.
> 

        @word = split /^|[\x20\f\t\r]+|$/m, $all_of_it;

You need to match either the start of a line (zero characters!), a 
group of whitespace characters except newline or the end of a line.

The /m tells Perl to match the ^ and $ at the start/end of each line, 
not just start/end of the string.

HTH, Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to