use warnings; use strict; use Data::Dump qw(dd); my @acutes = qw(193 A 201 E 205 I 211 O 218 U 225 a 233 e 237 i 243 o 250 u 221 Y 253 y); my @graves = qw(192 A 200 E 204 I 210 O 217 U 224 a 232 e 236 i 242 o 249 u); my @others = qw(228 a 246 o 223 ss); my %xlate = (@acutes, @graves, @others); # dd \%xlate; # FOR DEBUG my ($search) = map qr{[$_]}xms, join '', map sprintf('\%03o', $_), keys %xlate ; # dd $search; # FOR DEBUG while (my $line = ) { chomp $line; $line =~ s{ ($search) }{$xlate{ord $1}}xmsg; die "non-ascii in '$line'" if $line =~ m{ [[^:ascii:]] }xms; print "'$line' \n"; } __DATA__ spanish: Depósito Centralízado french: voilà: a word with an accent gravè vanilla: this is plain ascii other: gräßliches Tröten