in reply to md5_hex gives different values for same string

Can you use the eq operator to test that $cmd eq $check instead of $check =~ $cmd. It is possible that $check may contain additional (whitespace) characters and still match $cmd..

Replies are listed 'Best First'.
Re^2: md5_hex gives different values for same string
by jonsmith1982 (Beadle) on Oct 10, 2006 at 13:13 UTC
    changing =~ to eq does change the outcome but ive used chomp on both $cmd and $check before i use md5_hex and it still doesnt work.
      It would be logical that chomp isn't behaving the way you'd expect. Perhaps use regular expressions that explicitly state what you're trying to do until you're comfortable with how chomp functions. Or even write a function of your own.. e.g.
      sub remove_trailing_newlines( $ ) { my ( $stringref ) = @_; ${$stringref} =~ s/[\r\n]+\z//gs; }
      . Then call it instead of chomp. E.g.
      remove_trailing_newlines( \$cmd ); remove_trailing_newlines( \$check );
        sorted...
        $check =~ s/[\r\n]+\z//gs;
        thanks again.
      You're supposed to use eq, so just use eq.