[LA.pm] split() question

William Yardley lapm at veggiechinese.net
Thu Sep 28 11:19:12 PDT 2006


I'm doing some maintenance on a CPAN module I didn't write
(Mail::DeliveryStatus::BounceParser), and (around line 356 if anyone
needs to actually look there), we do something like:

foreach my $para (split /\n{2,}/, $delivery_status_body) {
      my $report = Mail::Header->new([split /\n/, $para]);

What's strange, is that in some cases, there is a leading \n left, which
results in $report not having the stuff we expect there. I'd assume that
since the \n{2,} should be greedy, there wouldn't be any \ns left after
that split. However, if I print out $para inside the loop, I see a
leading \n.

Simply doing a:
      $para =~ s/\A\n+//g;
in between those two lines "fixes" the problem - but I was wondering if
anyone know why this is happening.

w



More information about the Losangeles-pm mailing list