in reply to split mailbox one-liner

Not that we're golfing, but a "-n" loop that ends in "print" seems odd. {grin} I've used something like:
perl -pe 'open STDOUT, ">out".++$n if /^From /' <in >before-first-outp +ut
before, with the advantage that the original pre-first-From output ends up in a file that is not part of the series.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: •Re: split mailbox one-liner
by jrasillo (Initiate) on Mar 26, 2002 at 07:04 UTC
    I'm trying to do something like this but instead of comparing it to From I'm comparing it to From:, but it doesn't seem to be working. Here's the code if ($line =~ /^From:\b/){whatever}
      That's because a normal "mailbox format" file isn't delimited by "From:"... it's delimited by "^From ". What kind of file do you have that might possibly be delimited by From:?

      -- Randal L. Schwartz, Perl hacker