Gavin has asked for the wisdom of the Perl Monks concerning the following question:
while(<IN>) { $yline=$_; chomp($yline); $yline =~ s/\cM\cJ|\cM|\cJ/ /g; #returns et al $yline =~ s/^\s+//g; #Leading spaces $yline =~ s/\s\s+/ /g; #Trailing spaces @yline = split (/(?<=\.)/, $yline); #splits line but retains full + stop #@yline = split ($yline =~ /(.*?(?:\.|$))\s*/g);#grabs anything af +ter #@yline = split (/\./, $yline); foreach(@yline){ print "$_\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Capturing Space with Split
by Corion (Patriarch) on Mar 13, 2006 at 20:02 UTC | |
|
Re: Capturing Space with Split
by GrandFather (Saint) on Mar 13, 2006 at 20:14 UTC | |
by Gavin (Archbishop) on Mar 13, 2006 at 21:20 UTC | |
by GrandFather (Saint) on Mar 13, 2006 at 21:51 UTC | |
|
Re: Capturing Space with Split
by thundergnat (Deacon) on Mar 13, 2006 at 21:00 UTC |