The following code should work fine, assuming $data contains what you're trying to split:
#!/usr/bin/perl -w
use strict;
my $data = q|Title Line
Author Line
URL Line
|;
my @data = split /\s*\n\s*/, $data;
my $i;
for ($i=0; $i<=$#data; $i++){
print "$i: $data[$i]\n";
}
However, if you're reading from a file, i suspect you want something more like this:
#!/usr/bin/perl -w
use strict;
open DATA, 'splitdata.txt';
my @data;
while (<DATA>) {
chomp;
s|^\s+||;
s|\s+$||;
push @data, $_;
}
my $i;
for ($i=0; $i<=$#data; $i++){
print "$i: $data[$i]\n";
}
|