use strict; open (FH, 'hex_file.txt') or die $!; while () { s/([a-f0-9]{2})/hex($1)/egi; print; }