D
dutone
sample file:
+123n
blah blah blah
+123+
more blah
sasas
assa
+123+
open IN, "data" or die $!;
my @data = <IN>;
my @splitData = split /\+123(?:\+)?/, "@data";
for(@splitData) { print "LINE ** $_"; }
prints:
LINE ** LINE ** n
blah blah blah
LINE **
more blah
sasas
assa
LINE **
now i understand that split returns the number of matched items plus 1
if no limit is given.
so in order to weed the empty elements out will i always have to do
somthing like the following:
my @splitData = grep { $_ and length $_ > 0 and $_ !~ /^\s+$/ }
split /\+123(?:\+)?/, "@data";
or get a count on how many times /\+123(?:\+)?/ matches in @data and
use that for a limit?
thanks
+123n
blah blah blah
+123+
more blah
sasas
assa
+123+
open IN, "data" or die $!;
my @data = <IN>;
my @splitData = split /\+123(?:\+)?/, "@data";
for(@splitData) { print "LINE ** $_"; }
prints:
LINE ** LINE ** n
blah blah blah
LINE **
more blah
sasas
assa
LINE **
now i understand that split returns the number of matched items plus 1
if no limit is given.
so in order to weed the empty elements out will i always have to do
somthing like the following:
my @splitData = grep { $_ and length $_ > 0 and $_ !~ /^\s+$/ }
split /\+123(?:\+)?/, "@data";
or get a count on how many times /\+123(?:\+)?/ matches in @data and
use that for a limit?
thanks