Re: $head->get issues possibly.
David A Golden <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Message-ID | <5.2.0.9.2.20040405141701.00b49620@localhost> |
At 4/5/2004 01:01 PM, Roderick A. Anderson wrote:
>It seems the spammers are breaking more and more Internet rules ... :-)
Generally, I think it would be useful to have Mail::Box be able to validate
each of the major headers against these rules rather than to have users
have to do it. (E.g., if $msg->validFrom() ). (Mark, how hard would this
be to add?)
> The problems is the get method on some messages is returning null
>values and this causes other code later in the scripts to fail. The short
>questions is there a way to have the get methods to return at least an
>empty string?
For this purpose, where you don't really care if there is a header line or
if it's blank because you're creating a report, I'd just use this kind of
perl idiom:
my $from = $head->get('From') || '';
I wouldn't want Mail::Box to give me empty strings instead of undefined as
a blank header line is valid. There's really three (er, four)
states. Present with valid contents, present with invalid contents,
present and empty, and not-present. (With empty often just a subset of valid.)
David Golden