summaryrefslogtreecommitdiff
path: root/src/m-pop
diff options
context:
space:
mode:
Diffstat (limited to 'src/m-pop')
-rwxr-xr-xsrc/m-pop9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/m-pop b/src/m-pop
index 1a0e0ff..e7cebae 100755
--- a/src/m-pop
+++ b/src/m-pop
@@ -28,15 +28,21 @@ USAGE
open my $tty, '+<:unix', '/dev/tty' or die "Could not open /dev/tty: $!";
# Get UIDs of existing messages
-my ($mbox, $index, @existing_uids);
+my ($mbox, $index, $offset, $length, @existing_uids);
+$offset = -1;
+$length = 0;
if (-e $opt{i}) {
open $index, '<', $opt{i} or die "Could not open $opt{i}: $!";
local $/ = ''; # paragraph mode
while (<$index>) {
push @existing_uids, $1 if /^M-UID: (.*)$/m;
+ $offset = $1 if /^M-Offset: (.*)$/m;
+ $length = $1 if /^M-Length: (.*)$/m;
}
close $index;
}
+$offset += $length;
+$offset++;
# Open mbox and index files for appending
open $mbox, '>>', $opt{m} or die "Could not open $opt{m}: $!";
@@ -69,7 +75,6 @@ $SIG{INT} = sub {
# Append new messages to mbox and index files
chomp(my $date = asctime(localtime(time)));
-my $offset = 0;
my $i = 0;
for my $id (@ids) {