If the aim isn't to separate data and function :(my $output = $filter_clean) =~ s{ (\D) }{ $filter_map{uc $1} }exg;
use strict; use warnings; use 5.10.1; my $filter_clean = 'GaV18'; sub filter2num { local $_=shift; s/[ABC] /2/igx; s/[DEF] /3/igx; s/[GHI] /4/igx; s/[JKL] /5/igx; s/[MNO] /6/igx; s/[PQRS]/7/igx; s/[TUV] /8/igx; s/[WXYZ]/9/igx; return $_; } say filter2num($filter_clean);
In reply to Re^2: map and grep or clear code?
by brx
in thread map and grep or clear code?
by ghenry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |