Guest User

Untitled

a guest
Jun 19th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.92 KB | None | 0 0
  1. #Läser varje rad i specifik fil och konverterar den till en MD5-hash.
  2. #Printar ut HASHET och tecknet/ordet i följande form "MD5 = "@ORD"
  3. #Skriver en fil med hashet>ordet istället för 'print'
  4. #use strict; not now in 1.1
  5. #use Getopt::Std; -||-
  6. #my %options=();
  7. #getopts("h:j:l:", \%options);
  8. #print "-h $options{h}\n" if defined $options{h};
  9. #print "-j $options{j}\n" if defined $options{j};
  10. #print "-l $options{l}\n" if defined $options{l};
  11.  
  12. use Digest::MD5;
  13. print ("name of the file in curdir?: ");
  14. $file = <>;
  15.  
  16. open(INFO, $file) or die ("The $file does NOT exist.\n"); #VAR :D
  17.  
  18. foreach $line (<INFO>)  {  
  19.     $md5 = Digest::MD5->new;
  20.     $md5->add ($line);
  21.     $digest = $md5->hexdigest;    
  22. open OUTPUT, ">>output.txt";
  23. print OUTPUT "$digest = $line";
  24.                            
  25. if ($digest =~ s/A/O/) {
  26.     #print ("$digest = $line"); <-- en if-sats kan vara NULL om det är ett argument?    
  27. }
  28. }
  29. close(INFO);
  30. close OUTPUT;
Add Comment
Please, Sign In to add comment