my $directory = shift; my $BOM = "\x..."; # Fill in the actual problematic string $directory = s/$BOM//;