#!/usr/bin/perl -- use strict; use warnings; use Path::Tiny qw/ path /; my $infile = '...'; my $outfile = '...'; my $find = VerifyHex( '\xe9' ); my $replace = VerifyHex( '\x65' ); my $IF = path( $infile )->openr_raw; my $OF = path( $outfile )->openw_raw; while( my $str = <$IF> ){ $str =~ s{$find}{$replace}g; print $OF $str; } close $IF; close $OF; sub VerifyHex { my( $str ) = @_; if( $str =~ m/(\\[a-zA-Z0-9][a-zA-Z0-9])/ ){ return "$1"; } die "evil input $str"; }