in reply to Re^2: Deleting undefined entries from DB_FILE hash
in thread Deleting undefined entries from DB_FILE hash

Instead of this:

foreach my $key ( keys %hash ) { my @tmp = split /\t/, $hash{$key}, 7; my $type = $tmp[0]; my $dt = $tmp[1]; my ($year, $month, $day) = $dt =~ m|(\d{4})(\d{2})(\d +{2})T.*|;
Try this and see what you get:
foreach my $key ( keys %hash ) { my @tmp = split /\s+/, $hash{$key}; my $type = $tmp[0]; my $dt = $tmp[1]; my ($year, $month, $day) = ('','',''); if($dt =~ m|(\d{4})(\d{2})(\d+{2})T.*$|){ ($year, $month, $day)=($1,$2,$3); } ...... ...... printf("bucket: %s\ttype: %s\t%s-%s-%s\t%s\n",$bucket +,$type,$year,$month,$day,$dt); ......

Replies are listed 'Best First'.
Re^4: Deleting undefined entries from DB_FILE hash
by gossamer (Sexton) on Jul 24, 2012 at 02:34 UTC

    I actually just a few minutes ago removed the LIMIT from the split, and it made no difference alone.

    I also added the following line directly before the split line:

    if(!defined($hash{$key})) { print "key $key ($hash{$key}) not defined\ +n"; delete($hash{$key}); next; }

    For values where $hash{$key} isn't defined, it still outputs this:

    Use of uninitialized value in concatenation (.) or string at ./list_ha +sh.pl line 33. key spam-de102f8ac36e56326312e8701b3b4520-20120419T161342-05203-09-2.g +z () not defined

    In other words, the key (the spam-de... filename) is defined, but the rest of the values of the record are not.

    The rest of the values include the email's subject, so switching \t for \s+ won't work, because email subjects have spaces in them.

    If I run this program again, it prints the same 'uninitialized value' line at the same spot. Why doesn't it delete() the record? Eventually the hash is "untied", so it's properly closed. That's the issue that really has me perplexed now.

    Thanks,
    Alex