use 5.010; use strict; use warnings; my @map = qw [0 1 abc def ghi jkl mno pqrs tuv xyz]; my $words = `cat /usr/share/dict/words`; while (<DATA>) { chomp; s/[^0-9]+//g; s/[01]+/ /g; foreach my $_ (split) { my @c; for (my $i = 0; $i < length; $i++) { for (my $j = 2; $i + $j <= length; $j++) { push @c, substr $_, $i, $j; } } my $pat = join '|', map {my $_ = $_; s/(.)/[$map[$1]]/g; $_} @ +c; say for $words =~ /^($pat)$/mg; } } __DATA__ 234-5678
In reply to Re: Phone number to word conversion
by JavaFan
in thread Phone number to word conversion
by oko1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |