in reply to Perl Split
If you are new to Perl (or even if you aren't), I'd really recommend getting into the habit of using it. It can very quickly and easily show you what's going on with your data - and it becomes especially useful once you start working with more complex data structures.
With regards to your current problem, as Corion points out, you're probably just forgetting about the whitespace after each period (full stop).
To demonstrate how Data::Dumper::Simple could have helped you to easily see this for yourself, consider the following:
Which outputs:#!/usr/bin/perl -w use strict; use Data::Dumper::Simple; my @lines; while (<DATA>) { chomp; @lines = split (/(?<=\.)/, $_); } print Dumper(@lines); __DATA__ First line. Second Line. Third line. Fourth line.
So straight away it becomes apparent what's going on - ie. you are capturing the space after each period.@lines = ( 'First line.', ' Second Line.', ' Third line.', ' Fourth line.' );
Hope this helps,
Darren :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Split
by Gavin (Archbishop) on Mar 13, 2006 at 13:41 UTC | |
by xdg (Monsignor) on Mar 13, 2006 at 14:13 UTC | |
by McDarren (Abbot) on Mar 13, 2006 at 14:38 UTC | |
by Gavin (Archbishop) on Mar 13, 2006 at 20:07 UTC |