use strict; use warnings; my $test = "hello there ass\x08\x08wesome"; print "BEFORE: $test, ", "(length: " . length($test) . ")\n"; while ($test =~ /.\x08/) { $test = substr( $test, 0, $-[0] ) . substr( $test, $+[0] ); # Note: The preceeding line is the same as: # $test = $` . $'; # but avoids using $` and $', side-stepping the global # performance penalty associated with their use. } print "AFTER: $test, ", "(length: " . length($test) . ")\n";