in reply to Perl Split

Hi, Here is one way to do it.

local $/; $xline=<DATA>; chomp($xline); @xline = split (/(?<=\.)\s*/, $xline); foreach(@xline){ print "$_\n"; } __DATA__ This is my first line. This is my second line. This is my third line.

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Replies are listed 'Best First'.
Re^2: Perl Split
by graff (Chancellor) on Mar 14, 2006 at 04:09 UTC
    Depending on the properties of the data, one might be better off insisting on whitespace after period to define a full-stop:
    $_ = "Next line (2.) contains a url. The url is perlmonks.org. Send th +em \$20.00.\n"; @sentences = split(/(?<=\.)\s+/); print "$_\n" for ( @sentences );
    Of course, things like "Mr. Smith", etc. will make it... a little more complicated. (Full stops not followed by space "are left as an excercise for the reader.")