monger has asked for the wisdom of the Perl Monks concerning the following question:
What I want to do is modify the pattern matching in the if clause to add the year. Here's an example ^From line:#!/usr/bin/perl -w my $file = "./oldcoffee.tmp"; my $out = ">./coffee.tmp"; my @mails; open OUT, $out || die "Can't open $out!\n"; open FILE, $file || die "Can't open file oldcoffee!\n"; while (<FILE>) { if (/^From /) { $mails[$#mails + 1] = $_; } else { $mails[$#mails] .= $_; } print $OUT, @mails; } close FILE, $file || die "Can't close file oldcoffee!\n"; close OUT, $out || die "Can't close $out!\n";
From - Tue Jan 14 17:43:12 2003
I've looked at constructing a regex to account for the day, date and time, then iterate through for each year, 2003-2006. The regex got to be a bit cumbersome, so I tried this:
With this, I receive the following error:if (/^From - \+ 2003/)
Modification of non-creatable array value attempted, subscript -1 at ./mbox_orig.pl line 13, <FILE> line 1.
Any suggestions on how to tackle this? Thanks, monger
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Spliting an mbox file
by gellyfish (Monsignor) on Aug 15, 2006 at 18:34 UTC | |
|
Re: Spliting an mbox file
by Fletch (Bishop) on Aug 15, 2006 at 18:15 UTC | |
|
Re: Spliting an mbox file
by rodion (Chaplain) on Aug 15, 2006 at 18:52 UTC | |
|
Re: Spliting an mbox file
by jwkrahn (Abbot) on Aug 15, 2006 at 22:43 UTC | |
by parv (Parson) on Aug 16, 2006 at 01:53 UTC |