Apologies for the poor formatting on my previous post and thank you all for your input. So I am creating arrays to store the checksum of files and I do this twice as I have 2 directories. I am then trying to compare the arrays using the last bit of code. This is when the arrays go out of scope:

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.


In reply to Global variables question by PerlScholar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.