On Mon, Nov 17, 2008 at 6:00 AM, Gisle_Aas via RT <
bug-HTML-Parser@rt.cpan.org> wrote:
Show quoted text> <URL:
http://rt.cpan.org/Ticket/Display.html?id=27567 >
>
> I don't get why you want to suppress the warning when you are passing input
> that's not
> conforming to the specified interface. Is there a good reason for encoding
> undef as undef?
You are already doing it. That is, you already return undef if undef is
passed in:
msmbp:~ msouth$ perl -MHTML::Entities -MData::Dumper -e 'print +Dumper(
encode_entities(undef) )';
$VAR1 = undef;
This way you do it more quietly. The alternative is for the the caller to
have to either wrap their call in a no warnings pragma or call like
"encode_entities( $foo || '' )" to suppress the warning.
It is a very common case to have something that might be undefined, but if
it is defined I want the entities in it encoded.
The nice thing about this patch is that it doesn't affect old code (except
to suppress a warning). The documentation does not define what happens if
you pass in undef, so I don't think we would be hurting anyone. Maybe if
someone had warnings fatal and wanted that warning when an undef went in,
but that seems like a pretty farfetched and much less common use case than
the one where you have stuff coming in that might not be defined.
mike
mike