in reply to map and grep or clear code?
Personally I'd find a simple regex s/// simpler than all of the above:
use strict; use warnings; use 5.10.1; my $filter_clean = 'GAV18'; my %filter_map = ( A => 2, B => 2, # ... Y => 9, Z => 9, ); $filter_map{$_} = $_ for 0..9; (my $output = uc $filter_clean) =~ s{ (.) }{ $filter_map{$1} }exg; say $output;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: map and grep or clear code?
by brx (Pilgrim) on Jan 31, 2012 at 18:59 UTC | |
by tobyink (Canon) on Jan 31, 2012 at 19:16 UTC |