Advertisement
Guest User

Untitled

a guest
Dec 9th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1.  
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use File::Basename;
  7.  
  8. sub usage()
  9. {
  10. print "./parse_md5 <original> <compare> \n";
  11. exit 1;
  12. }
  13.  
  14. my $orig=$ARGV[0];
  15. my $compare=$ARGV[1];
  16.  
  17.  
  18. usage() if (!$orig) ;
  19. usage() if (!$compare) ;
  20.  
  21.  
  22.  
  23. my $orig_hash = parse_hash($orig);
  24. my $compare_hash = parse_hash($compare);
  25.  
  26.  
  27. foreach my $key (keys(%$compare_hash))
  28. {
  29. print "Check file '$key' ";
  30.  
  31. if ( $$orig_hash{$key} )
  32. {
  33. if ( $$orig_hash{$key} eq $$compare_hash{$key} )
  34. {
  35. print "ok\n"
  36. }
  37. else
  38. {
  39. print "FAIL FAIL FAIL!\n";
  40. }
  41. }
  42. else
  43. {
  44. print "NOT FOUND\n";
  45. }
  46. }
  47.  
  48.  
  49. sub parse_hash
  50. {
  51. my ($filename)=@_;
  52.  
  53.  
  54. my $fid;
  55.  
  56. open($fid, "<".$filename) or die "Cannot open: '$filename': $!\n";
  57.  
  58. my $hash = {};
  59.  
  60. while (my $line=<$fid>)
  61. {
  62. chop($line);
  63. #10dc30df64d4dc8cc5cea5c1a492a344 maemo4-sdk/Release
  64. next if !$line;
  65. if ($line=~/\s*([\w\d]+)\s+([\w\d\-\_\/\.]+)\s*$/)
  66. {
  67. my($file, $directories, $suffix) = fileparse($2);
  68. print "Found $file -> $1 \n";
  69. $$hash{$file} = $1;
  70. }
  71. else
  72. {
  73. die ("Unkown line: $line\n");
  74. }
  75.  
  76. }
  77. return $hash;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement