in reply to Re^2: Checking MD5 of files in directory with corresponding MD5 file type
in thread Checking MD5 of files in directory with corresponding MD5 file type

Think about it, what do the strings contain? Will "md2" =~ "md1\nmd2\nmd3\n" match?
  • Comment on Re^3: Checking MD5 of files in directory with corresponding MD5 file type
  • Download Code

Replies are listed 'Best First'.
Re^4: Checking MD5 of files in directory with corresponding MD5 file type
by james28909 (Deacon) on Dec 31, 2016 at 16:24 UTC

    Well, the $md5_string, as the variable name insists, contains thousands of md5s in a single string. To me it would make better sense for the lhs to be $md5 and rhs be $md5_string, which is saying "does this files $md5 match anywhere in the long list of md5's". So logically, I would assume it would be better written as 'if ( $md5 =~ /.*$md5_string.*/ ){' but in previous attempts to get it to work like that it failed. maybe it is because of how I were comparing. Ill go back and retry when I get home.

      Maybe what you're thinking is chomp(@md5_file); my $md5_re = join "|", map quotemeta, @md5_file; and then later if ($md5=~/^($md5_re)$/){.

      But why not use a hash?