This is the code:
my $t = "abc\nfoo\nbar";
my @a = split(/\n/g, $t);
print $#a . " lines\n";
foreach my $x (@a) {
print 'line: ' . $x . "\n";
}
It prints:
2 lines
line: abc
line: foo
line: bar
Why 2 lines
while there are three lines? :)