| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Text::T9; | 
| 2 | 1 |  |  | 1 |  | 5845 | use Exporter; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 42 |  | 
| 3 | 1 |  |  | 1 |  | 5 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 35 |  | 
| 4 | 1 |  |  | 1 |  | 6 | use warnings; | 
|  | 1 |  |  |  |  | 14 |  | 
|  | 1 |  |  |  |  | 32 |  | 
| 5 | 1 |  |  | 1 |  | 6 | use Carp; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 311 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $VERSION = '1.01'; | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | our @ISA = qw( Exporter ); | 
| 10 |  |  |  |  |  |  | our @EXPORT = qw( t9_find_words ); | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | our @T9NL = ( '', '', 'ABC', 'DEF', 'GHI', 'JKL', 'MNO', 'PQRS', 'TUV', 'WXYZ' ); | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | sub t9_find_words($$) | 
| 15 |  |  |  |  |  |  | { | 
| 16 | 4 |  |  | 4 | 1 | 347 | my $num = shift; | 
| 17 | 4 |  |  |  |  | 5 | my $words = shift; | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 4 | 50 |  |  |  | 24 | return () unless $num =~ /^[2-9]+$/; | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 4 |  |  |  |  | 6 | my $len = length( $num ); | 
| 22 | 4 |  |  |  |  | 5 | my $re; | 
| 23 | 4 |  |  |  |  | 10 | for( 0 .. $len - 1 ) | 
| 24 |  |  |  |  |  |  | { | 
| 25 | 17 |  |  |  |  | 41 | $re .= "[" . $T9NL[substr( $num, $_, 1 )] . "]"; | 
| 26 |  |  |  |  |  |  | } | 
| 27 | 4 |  |  |  |  | 9 | $re = "^$re\$"; | 
| 28 | 4 |  |  |  |  | 10 | return grep { /$re/i } grep { length( $_ ) == $len } @$words; | 
|  | 14 |  |  |  |  | 243 |  | 
|  | 40 |  |  |  |  | 62 |  | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | =pod | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | =head1 NAME | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | Text::T9 - Text in 9 keys (T9) input. | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | # array with words | 
| 40 |  |  |  |  |  |  | my @words = qw( this is just a simple kiss test lips here how ); | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | # what is word(s) for the sequence | 
| 43 |  |  |  |  |  |  | print "$_ " for( t9_find_words( 5477, \@words ) ); | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | # this prints: kiss lips | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | What is T9 Text Input? | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | T9 Text Input is software that enables users to easily enter text | 
| 52 |  |  |  |  |  |  | into small devices with limited size keyboards, like mobile phones. | 
| 53 |  |  |  |  |  |  | T9 Text Input replaces the traditional "multi-tap" method of entering | 
| 54 |  |  |  |  |  |  | text providing the ability to enter text using only one keystroke per | 
| 55 |  |  |  |  |  |  | letter. | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | (you can find more inforation at http://www.t9.com/) | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | This module provides simple way to find which words match a number | 
| 60 |  |  |  |  |  |  | sequence in T9 sense. | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | Examples: | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | 5477   : KISS, LIPS | 
| 65 |  |  |  |  |  |  | 8447   : THIS | 
| 66 |  |  |  |  |  |  | 746753 : SIMPLE | 
| 67 |  |  |  |  |  |  | 469    : HOW | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | Allowed number are 2,3,4,5,6,7,8,9 which are mapped in this way: | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | 2 ABC | 
| 72 |  |  |  |  |  |  | 3 DEF | 
| 73 |  |  |  |  |  |  | 4 GHI | 
| 74 |  |  |  |  |  |  | 5 JKL | 
| 75 |  |  |  |  |  |  | 6 MNO | 
| 76 |  |  |  |  |  |  | 7 PQRS | 
| 77 |  |  |  |  |  |  | 8 TUV | 
| 78 |  |  |  |  |  |  | 9 WXYZ | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | =over 4 | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | =item t9_find_words( $num, \@words_arr ) | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | This functions takes two arguments: number sequence and words array | 
| 85 |  |  |  |  |  |  | reference. The return value is a list of matching words. | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | =back | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =head1 EXAMPLES | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | open( i, "/tmp/words.lst" ); | 
| 92 |  |  |  |  |  |  | @words = ; | 
| 93 |  |  |  |  |  |  | close( i ); | 
| 94 |  |  |  |  |  |  | chomp( @words ); | 
| 95 |  |  |  |  |  |  | print "$#words were loaded\n"; | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | for my $num ( qw( 5477 8447 746753 469 ) ) | 
| 98 |  |  |  |  |  |  | { | 
| 99 |  |  |  |  |  |  | print "$num: "; | 
| 100 |  |  |  |  |  |  | print "$_ " for( t9_find_words( $num, \@words ) ); | 
| 101 |  |  |  |  |  |  | print "\n"; | 
| 102 |  |  |  |  |  |  | } | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | =head1 AUTHOR | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | Vladi Belperchinov-Shabanski "Cade" | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | http://cade.datamax.bg | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | =cut |