in reply to Can't update file

One issue I spotted immediately is this line:

if ( $md5row = $md5chksum )

The = is the assignment operator (which will return true, hence the else isn't being triggered). You need an equality operator (==) which checks whether the value on the left is equal to the value on the right. However, in this case, you're dealing with strings, so you need the eq operator. == is for numeric comparisons. So you need to change the above line to:

if ( $md5row eq $md5chksum )

Note that there may be other issues with the code, this was just a glaring one.