A
Anonymous user
Hello,
i can't manage to make my program work, and i don't understand the
error. I have the lines:
$_ = $dst;
my $test =~ m/\.pl\$/; # Use of uninitialized value in pattern match
(m//) at copy.pl line 33.
i would like to put in my variable the result of the extension test.
Seems pretty simple...
Here is my source code:
----------------------------------------------------------- 8<
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Find;
use File::Basename;
use File::Copy;
use File:ath;
# global variables
use vars qw( $src_dir $dst_dir );
my ($src_dir, $dst_dir) = @ARGV;
sub copy_file {
my $src = $File::Find::name;
# remove the beginning of the path
$_ = "$src";
s!\Q$src_dir!!;
# destination
my $dst = "$dst_dir/$_";
# is it a directory?
if ( -d $src ) {
mkpath([ $dst ]);
} else {
# if it's a perl file, say it!
if (copy($src, $dst)) {
$_ = $dst;
my $test =~ m/\.pl\$/; # Use of uninitialized value in pattern match
(m//) at copy.pl line 33.
if ($test) {
print("Perl file found: $dst\n");
}
} else {
print STDERR "Can't copy file $src to $dst: $!\n";
}
}
}
# create the root destination directory
mkpath([ $dst_dir ]);
find(\©_file, $src_dir);
----------------------------------------------------------- 8<
Thx for any help
i can't manage to make my program work, and i don't understand the
error. I have the lines:
$_ = $dst;
my $test =~ m/\.pl\$/; # Use of uninitialized value in pattern match
(m//) at copy.pl line 33.
i would like to put in my variable the result of the extension test.
Seems pretty simple...
Here is my source code:
----------------------------------------------------------- 8<
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Find;
use File::Basename;
use File::Copy;
use File:ath;
# global variables
use vars qw( $src_dir $dst_dir );
my ($src_dir, $dst_dir) = @ARGV;
sub copy_file {
my $src = $File::Find::name;
# remove the beginning of the path
$_ = "$src";
s!\Q$src_dir!!;
# destination
my $dst = "$dst_dir/$_";
# is it a directory?
if ( -d $src ) {
mkpath([ $dst ]);
} else {
# if it's a perl file, say it!
if (copy($src, $dst)) {
$_ = $dst;
my $test =~ m/\.pl\$/; # Use of uninitialized value in pattern match
(m//) at copy.pl line 33.
if ($test) {
print("Perl file found: $dst\n");
}
} else {
print STDERR "Can't copy file $src to $dst: $!\n";
}
}
}
# create the root destination directory
mkpath([ $dst_dir ]);
find(\©_file, $src_dir);
----------------------------------------------------------- 8<
Thx for any help