in reply to Re^4: problem with sysseek in loop
in thread problem with sysseek in loop
my $dirname = "extracted"; open (my $md5file, '<', "C:/md5"); binmode($md5file); foreach my $file (<$dirname/*>) { next if -d $file; open( my $FILE, $file ); binmode($FILE); $file =~ s{.*/}{}; my $md5hash = Digest::MD5->new->addfile($FILE)->hexdigest; if ($md5hash =~ $md5file){ print "$file MATCH\n"; } else { print "$file NO MATCH!\n"; } }
as this would enable you to better visualize the logical structure and detect possible problems or bugs.my $dirname = "extracted"; open (my $md5file, '<', "C:/md5"); binmode($md5file); foreach my $file (<$dirname/*>) { next if -d $file; open( my $FILE, $file ); binmode($FILE); $file =~ s{.*/}{}; my $md5hash = Digest::MD5->new->addfile($FILE)->hexdigest; if ($md5hash =~ $md5file){ print "$file MATCH\n"; } else { print "$file NO MATCH!\n"; } }
Concerning subroutines, yes, by all means, learn them, this is quite easy and necessary. The perlsub document tells you more or less everything about them, but it has probably far more details than what you need or want for a start. For an easier introduction to them, read the relevant section (http://perldoc.perl.org/perlintro.html#Writing-subroutines) of the perlintro document, but don't read only the section on subs, reading the full document would probably be very useful to you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: problem with sysseek in loop
by james28909 (Deacon) on May 08, 2014 at 15:43 UTC |