$_ = "this is an\b correct usage"; my $buff = ''; while (m/(.)/g) { if ($1 eq "\b") { chop($buff) } else { $buff .= $1 } } print $buff;