Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- use File::Basename;
- sub usage()
- {
- print "./parse_md5 <original> <compare> \n";
- exit 1;
- }
- my $orig=$ARGV[0];
- my $compare=$ARGV[1];
- usage() if (!$orig) ;
- usage() if (!$compare) ;
- my $orig_hash = parse_hash($orig);
- my $compare_hash = parse_hash($compare);
- foreach my $key (keys(%$compare_hash))
- {
- print "Check file '$key' ";
- if ( $$orig_hash{$key} )
- {
- if ( $$orig_hash{$key} eq $$compare_hash{$key} )
- {
- print "ok\n"
- }
- else
- {
- print "FAIL FAIL FAIL!\n";
- }
- }
- else
- {
- print "NOT FOUND\n";
- }
- }
- sub parse_hash
- {
- my ($filename)=@_;
- my $fid;
- open($fid, "<".$filename) or die "Cannot open: '$filename': $!\n";
- my $hash = {};
- while (my $line=<$fid>)
- {
- chop($line);
- #10dc30df64d4dc8cc5cea5c1a492a344 maemo4-sdk/Release
- next if !$line;
- if ($line=~/\s*([\w\d]+)\s+([\w\d\-\_\/\.]+)\s*$/)
- {
- my($file, $directories, $suffix) = fileparse($2);
- print "Found $file -> $1 \n";
- $$hash{$file} = $1;
- }
- else
- {
- die ("Unkown line: $line\n");
- }
- }
- return $hash;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement