Subject: | [PATCH] 1.21: Net/Cmd.pm: fixup utf8 stuff |
Date: | Tue, 21 Aug 2007 16:04:28 +0400 |
To: | bug-libnet [...] rt.cpan.org |
From: | Alexey Tourbin <at [...] altlinux.ru> |
perldoc utf8 says:
Do not use this pragma for anything else than telling Perl that your
script is written in UTF-8. The utility functions described below are
directly usable without "use utf8;".
perldoc utf8 also says:
$flag = utf8::is_utf8(STRING); # since Perl 5.8.1
So, we should not explicitly use or require utf8, but, provided
that we have perl >= 5.8.1, just invoke the code.
---
Net/Cmd.pm | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/Net/Cmd.pm b/Net/Cmd.pm
index 355b6c9..7fa73b7 100644
--- a/Net/Cmd.pm
+++ b/Net/Cmd.pm
@@ -22,8 +22,6 @@ BEGIN {
}
}
-my $doUTF8 = eval { require utf8 };
-
$VERSION = "2.28";
@ISA = qw(Exporter);
@EXPORT = qw(CMD_INFO CMD_OK CMD_MORE CMD_REJECT CMD_ERROR CMD_PENDING);
@@ -386,7 +384,7 @@ sub datasend {
my $arr = @_ == 1 && ref($_[0]) ? $_[0] : \@_;
my $line = join("", @$arr);
- if ($doUTF8) {
+ if ($] > 5.008) { # >= 5.8.1
# encode to individual utf8 bytes if
# $line is a string (in internal UTF-8)
utf8::encode($line) if utf8::is_utf8($line);
--
1.5.2.4.GIT