Also this:
>perl -wMstrict -le "my %replace = (rabbit => 'pap', triangle => 'tri', andso => 'on'); ; my $search = join '|', keys %replace; $search = qr{ $search }xmsi; ; while (<>) { last if m{\A \s* \z}xms; s{ \b ($search) \b }{ $replace{lc $1} }xmsge; print qq{'$_'}; } " Andso rabbit Xrabbit rabbitX XrabbitX RaBbIt 'on pap Xrabbit rabbitX XrabbitX pap ' Triangle Triangles 'tri Triangles '
See also perlretut, perlreref, perlrequick.
In reply to Re: Pattern matching with hash keys
by AnomalousMonk
in thread Pattern matching with hash keys
by tej
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |