Subject: | "Use of uninitialized value in uc" on Perl 5.12.1 |
It seems that the behaviour of uc() for undefined values changed with
recent Perl versions, it produces a warning on 5.12.1:
mendel@server1:~$ perl -wE 'say $^V; my $x = uc undef;'
v5.10.1
mendel@server1:~$
mendel@server2:~$ perl -wE 'say $^V; my $x = uc undef;'
v5.12.1
Use of uninitialized value in uc at -e line 1.
mendel@server2:~$
Consequently the code in lines 1483, 1484 and 1796 produce a warning on
Perl 5.12.1. The attached patch fixes it (and includes a test for it, too).
Subject: | Net-FTPSSL-0.20-uc_fix.diff |
diff -Naur a/Net-FTPSSL-0.20/FTPSSL.pm b/Net-FTPSSL-0.20/FTPSSL.pm
--- a/Net-FTPSSL-0.20/FTPSSL.pm 2012-01-01 18:48:03.000000000 +0100
+++ b/Net-FTPSSL-0.20/FTPSSL.pm 2012-01-10 16:46:23.000000000 +0100
@@ -1480,8 +1480,11 @@
# A true boolean func, should never call croak!
sub supported {
my $self = shift;
- my $cmd = uc (shift); # uc() converts undef to "".
- my $site_cmd = uc (shift);
+ my $cmd = shift;
+ my $site_cmd = shift;
+
+ $cmd = uc ($cmd) if defined $cmd;
+ $site_cmd = uc ($site_cmd) if defined $site_cmd;
my $result = 0; # Assume invalid FTP command
@@ -1793,7 +1796,7 @@
sub _help {
# Only shift off self, bug otherwise!
my $self = shift;
- my $cmd = uc ($_[0]); # Will convert undef to "". (Do not do a shift!)
+ my $cmd = defined $_[0] ? uc ($_[0]) : undef; # Do not do a shift!
# Check if requesting a list of all commands or details on specific command.
my $all_cmds = (! defined $_[0]);
diff -Naur a/Net-FTPSSL-0.20/t/10-complex.t b/Net-FTPSSL-0.20/t/10-complex.t
--- a/Net-FTPSSL-0.20/t/10-complex.t 2011-09-26 20:05:30.000000000 +0200
+++ b/Net-FTPSSL-0.20/t/10-complex.t 2012-01-16 12:55:47.000000000 +0100
@@ -14,12 +14,12 @@
# Proper values are: debug0, debug1, debug2 & debug3. 3 is the most verbose!
# use IO::Socket::SSL qw(debug3);
-use Test::More tests => 60; # Also update skipper (one less)
+use Test::More tests => 61; # Also update skipper (one less)
use File::Copy;
-my $skipper = 59;
+my $skipper = 60;
-# plan tests => 59; # Can't use due to BEGIN block
+# plan tests => 60; # Can't use due to BEGIN block
BEGIN { use_ok('Net::FTPSSL') } # Test # 1
@@ -145,7 +145,14 @@
isa_ok( $ftp, 'Net::FTPSSL', 'Net::FTPSSL object creation' );
- ok( $ftp->login ($user, $pass), "Login to $server" );
+ {
+ my $warnings = "";
+ local $SIG{__WARN__} = sub {
+ $warnings .= $_[0];
+ };
+ ok( $ftp->login ($user, $pass), "Login to $server" );
+ is( $warnings, "", "Login produces no warnings" );
+ }
# Turning off croak now that our environment is correct!
$ftp->set_croak (0);