Subject: | error message when stringifying a studied empty field |
Hi,
sometimes people don't write anything in their Subject: line.
When I $msg->study('subject') and then print (stringify) the result, the
error message
Use of uninitialized value $decoded[0] in join or string at
/usr/share/perl5/Mail/Message/Field/Full.pm line 317
is displayed, even though defaultTrace is set to ERRORS (see attached
sample script and mailbox).
I would expect this to quietly stringify to an empty string.
Florian
Subject: | folder.mbox |
Message body not shown because it is not plain text.
Subject: | stringify.pl |
#!/usr/bin/perl -w
use strict;
use Mail::Box::Manager;
my $mgr = Mail::Box::Manager->new;
Mail::Reporter->defaultTrace('ERRORS');
my $folder = $mgr->open(folder => 'folder.mbox', access => 'rw') or die "cannot open folder.mbox: $!\n";
foreach my $msg ($folder->messages) {
my $subject = $msg->study('subject');
print "ok so far\n";
print "Subject is '$subject'\n";
print "(error above)\n";
# WORKAROUND:
if (defined $subject && $subject ne '') {
# print $subject...
}
# ... do other stuff ...
}