PerlScholar has asked for the wisdom of the Perl Monks concerning the following question:
for my $entry(@files1) {
my $readfile = "$dir1\\$entry";
#print "$readfile\n";
if (-e $readfile && -r $readfile){
open (FILE, $readfile) or die "Error opening: '$readfile': $!";
binmode(FILE);
my $md5 = Digest::MD5->new;
$md5-> b64digest;
while (<FILE>) {
$md5->add($_);
}
my @digest1 = $md5->b64digest;
#print "@digest1\n";#This array will go out of scope
print "$readfile: @digest1\n";
}
close (FILE);
} print "\n";
#2nd directory
for my $entry(@files2) {
my $readfile = "$dir2\\$entry";
#print "$readfile\n";
if (-e $readfile && -r $readfile){
open (FILE, $readfile) or die "Error opening: '$readfile': $!";
binmode(FILE);
my $md5 = Digest::MD5->new;
$md5-> b64digest;
while (<FILE>) {
$md5->add($_);
}
my @digest2 = $md5->b64digest;#This array will go out of scope
print "$readfile: @digest2\n";
}
close (FILE);
}
#compare directories
my $equals = 1;
foreach (my $i = 0; $i <@digest1; $i++) {
if (my $digest1[$i] ne my $digest2[$i]){
$equals = 0;
}
else {
$equals = 1;
}
print "$equals";
}
Error messages
Global symbol "@digest1" requires explicit package name at Z:/My Documents/Workspace/DeployChecker/Test.pl line 101.
syntax error at Z:/My Documents/Workspace/DeployChecker/Test.pl line 102, near "$digest1["
syntax error at Z:/My Documents/Workspace/DeployChecker/Test.pl line 105, near "else"
Execution of Z:/My Documents/Workspace/DeployChecker/Test.pl aborted due to compilation errors.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Global variables question
by jwkrahn (Abbot) on Aug 24, 2010 at 02:06 UTC | |
|
Re: Global variables question
by dasgar (Priest) on Aug 23, 2010 at 23:26 UTC | |
|
Re: Global variables question
by JavaFan (Canon) on Aug 24, 2010 at 10:20 UTC | |
by PerlScholar (Acolyte) on Aug 24, 2010 at 10:51 UTC | |
|
Re: Global variables question
by Marshall (Canon) on Aug 24, 2010 at 12:13 UTC | |
by PerlScholar (Acolyte) on Aug 24, 2010 at 14:43 UTC | |
by Marshall (Canon) on Aug 24, 2010 at 16:50 UTC | |
by PerlScholar (Acolyte) on Aug 24, 2010 at 22:36 UTC | |
by Marshall (Canon) on Aug 26, 2010 at 18:43 UTC | |
| |
|
Re: Global variables question
by Marshall (Canon) on Aug 24, 2010 at 03:59 UTC |