Subject: | Patch for backwards compatibility before 5.6 |
There are only a few things preventing File::Copy::Recursive from being
backwards compatible before Perl 5.6:
* use warnings
* lexical directory handles
* our variables
None of these are critical to the operation of the module itself. A
fairly trivial patch will make this excellent module useful for Perls
before 5.6. (See attachment.)
I use this module for tests in CPAN::Reporter, and would really
appreciate having improved backwards compatibility.
Subject: | Recursive.pm-backcompatible.patch |
--- Recursive.pm.old 2006-10-01 05:02:40.000000000 -0400
+++ Recursive.pm 2006-10-01 05:36:36.000000000 -0400
@@ -1,6 +1,10 @@
package File::Copy::Recursive;
use strict;
+BEGIN {
+ # Keep older versions of Perl from trying to use lexical warnings
+ $INC{"warnings.pm"} = "faked" if $] < 5.006;
+}
use warnings;
use Carp;
@@ -8,22 +12,27 @@
use File::Spec; #not really needed because File::Copy already gets it, but for good measure :)
require Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT_OK = qw(fcopy rcopy dircopy fmove rmove dirmove pathmk pathrm pathempty pathrmdir);
-our $VERSION = '0.28';
-
-our $MaxDepth = 0;
-our $KeepMode = 1;
-our $CPRFComp = 0;
-our $CopyLink = eval { local $SIG{'__DIE__'};symlink '',''; 1 } || 0;
-our $PFSCheck = 1;
-our $RemvBase = 0;
-our $NoFtlPth = 0;
-our $ForcePth = 0;
-our $CopyLoop = 0;
-our $RMTrgFil = 0;
-our $RMTrgDir = 0;
-our $CondCopy = {};
+use vars(qw/
+ @ISA @EXPORT_OK $VERSION $MaxDepth $KeepMode $CPRFComp $CopyLink $PFSCheck
+ $RemvBase $NoFtlPth $ForcePth $CopyLoop $RMTrgFil $RMTrgDir $CondCopy
+/);
+
+@ISA = qw(Exporter);
+@EXPORT_OK = qw(fcopy rcopy dircopy fmove rmove dirmove pathmk pathrm pathempty pathrmdir);
+$VERSION = '0.28';
+
+$MaxDepth = 0;
+$KeepMode = 1;
+$CPRFComp = 0;
+$CopyLink = eval { local $SIG{'__DIE__'};symlink '',''; 1 } || 0;
+$PFSCheck = 1;
+$RemvBase = 0;
+$NoFtlPth = 0;
+$ForcePth = 0;
+$CopyLoop = 0;
+$RMTrgFil = 0;
+$RMTrgDir = 0;
+$CondCopy = {};
my $samecheck = sub {
return if $^O eq 'MSWin32'; # need better way to check for this on winders...
@@ -171,9 +180,9 @@
}
$level++;
- opendir(my $pth_dh, $str) or return;
- my @files = grep( $_ ne '.' && $_ ne '..', readdir($pth_dh));
- closedir $pth_dh;
+ opendir(PTH_DH, $str) or return;
+ my @files = grep( $_ ne '.' && $_ ne '..', readdir(PTH_DH));
+ closedir PTH_DH;
for my $file (@files) {
my ($file_ut) = $file =~ m{ (.*) }xms;
@@ -238,8 +247,8 @@
sub pathempty {
my $pth = shift;
return 2 if !-d $pth;
- opendir(my $pth_dh, $pth) or return;
- for my $name (grep !/^\.+$/, readdir($pth_dh)) {
+ opendir(PTH_DH, $pth) or return;
+ for my $name (grep !/^\.+$/, readdir(PTH_DH)) {
my ($name_ut) = $name =~ m{ (.*) }xms;
my $flpth = File::Spec->catdir($pth, $name_ut);
if(-d $flpth) {
@@ -248,7 +257,7 @@
unlink $flpth or return;
}
}
- closedir $pth_dh;
+ closedir PTH_DH;
1;
}