You are comparing strings, not numbers, so do use eq
.
Also use lc()
, and chomp()
or $a=~s/^\s+//;$a=~s/\s+$//;
.
You do have the pretty decent option of converting the input to numbers with hex()
and using ==
.
Try:
if (hex($a) == hex($b)){}
This all depends on how well you're handling the output of your md5sum
command. Mine looks like this:
dlamblin$ md5 .bash_history
MD5 (.bash_history) = 61a4c02cbd94ad8604874dda16bdd0d6
So I process it with this:
dlamblin$ perl -e '$a=`md5 .bash_history`;$a=~s/^.*= |\s+$//g;print $a,"\n";'
61a4c02cbd94ad8604874dda16bdd0d6
Now I do notice that hex()
has an integer overflow error on this so you'll want to use bigint;
dlamblin$ perl -e '
$a=`md5 .bash_history`;$a=~s/^.*= |\s+$//g;print hex($a),"\n";'
Integer overflow in hexadecimal number at -e line 1.
1.29790550043292e+38
dlamblin$ perl -Mbigint -e '
$a=`md5 .bash_history`;$a=~s/^.*= |\s+$//g;print hex($a),"\n";'
129790550043292010470229278762995667158