in reply to Show mbox files with unread mail messages in them

AFAIK there is no metadata in an mbox file that determines if a particular message has been read or not? Please correct me if I am wrong.

The first thing I did was to run the podchecker program on yours and it produced two syntax errors.

Some comments:

159 sub wanted 160 { 161 my $file = $File::Find::name; 162 163 # 164 # We only care about files. 165 # 166 return if ( -d $file );

I guess you are assuming that there are no named pipes or FIFOs or other types of files?

167 168 # 169 # Skip some mailboxes. 170 # 171 foreach my $exclude ( split( /,/, $CONFIG{'exclude'} ) )

What if you have a file name with a comma in it?

172 { 173 if ( $file =~ /$exclude/i )

What if you have a file name with a regex meta-character in it? What if the contents of $exclude are a subset of a larger file name? $file includes the complete path so $exclude could match on one of the path names. What if you want to exclude 'file' but not 'FILE'?

174 { 175 $CONFIG{'verbose'} && print "Excluded mail file: $ +file\n"; 176 return; 177 } 178 } 179 180 181 # 182 # Skip files if they've not been modified too recently. 183 # 184 my $time = -M $file; 185 if ( defined( $time ) ) 186 { 187 if ( $time > $CONFIG{'time'} ) 188 { 189 $CONFIG{'verbose'} && print "Mail file not modifie +d recently: $file\n"; 190 return; 191 } 192 } 193 else 194 { 195 $CONFIG{'verbose'} && print "Failed to stat: $file - $ +!\n";

You report an error if you cannot stat the file but not at line 166?

196 return; 197 }

HTH

Edit: g0n - moved comments out of code tags

Replies are listed 'Best First'.
Re^2: Show mbox files with unread mail messages in them
by skx (Parson) on May 29, 2006 at 10:21 UTC
    AFAIK there is no metadata in an mbox file that determines if a particular message has been read or not?

    If you're using Mutt like me then a new header is added 'Status: RO' for "read" and "old" when a message is read. This may be something other programs add, or it may be mutt-specific. I'm not sure.

    I guess you are assuming that there are no named pipes or FIFOs or other types of files?

    Yes, but I think that is a valid assumption in this case.

    I think your comments on the exclusion of filenames being very simplistic are very valid, but for simple code it works well for me. I guess I'm lucky that I don't have any meta-characters in my mailbox names.

    I've updated the node to fix the pod errors you pointed out, so thanks for those.

    Steve
    --