Subject: | [patch] Prevent a warning when checking Encode version |
Hello Yusuke,
XML::TreePP is used at work, and recently I was asked to take
a look at it because of unwanted warnings, which fill the logs.
The problem lies in the fact that we mostly use Debian sarge,
which is shipped with Perl 5.8.4, which includes Encode 1.99_01.
When the method encode_from_to() is called, it generates this
warning: Argument "1.99_01" isn't numeric in numeric lt (<)
at .../XML/TreePP.pm line 882
I proposed a patch for the calling to silence the warning.
Here is a similar patch, now for XML::TreePP itself.
Also, depending on how often this method is called (I don't
maintain the code which makes use of XML::TreePP), I'd suggest
to move $check at package level so it's evaluated only once.
A even better optimisation (but harder to do) would be to inline
all the small parts in this method so that when it is called,
only the code for the current versions of Perl and Encode are
executed.
Thanks in advance
--
Close the world, txEn eht nepO.
Subject: | XML-TreePP-0.36-version-check.diff |
diff -ru XML-TreePP-0.36-orig/lib/XML/TreePP.pm XML-TreePP-0.36-new/lib/XML/TreePP.pm
--- XML-TreePP-0.36-orig/lib/XML/TreePP.pm 2008-10-26 07:17:10.000000000 +0100
+++ XML-TreePP-0.36-new/lib/XML/TreePP.pm 2008-12-25 20:07:15.000000000 +0100
@@ -1095,7 +1095,11 @@
if ( $] >= 5.008 ) {
&load_encode();
- my $check = ( $Encode::VERSION < 2.13 ) ? 0x400 : Encode::FB_XMLCREF();
+ my $check = do {
+ local $SIG{__WARN__} = sub {};
+ $Encode::VERSION < 2.13 ? 0x400 : Encode::FB_XMLCREF();
+ };
+
if ( $] >= 5.008001 && utf8::is_utf8( $$txtref ) ) {
if ( $to =~ /^utf-?8$/i ) {
# skip