| Text-Toalpha documentation | Contained in the Text-Toalpha distribution. |
Text::Toalpha - Convert arbitary characters into letters
use Text::Toalpha qw(:all); my $alpha = toalpha($var); my $orig = fromalpha($alpha);
Text::Toalpha converts arbitary characters into letters. The interface is the functions toalpha($var) and fromalpha($alpha). They do what there names suggest.
NOTE: This module does not use a code format used anywhere else.
NOTE 2: The code for this module is not a good example and is very messy.
Text::Toalpha uses a mapping table from characters to letters which maps them into digrams. Need more be said?
The resulting output will double in size.
The permutation of characters to letters is not very well permutated. In English, the output characters are not very well distributed over the letters of the alphabet.
isalpha
Samuel Lauber, <samuell@cpan.org>
Copyright 2005 by Samuel Lauber
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Text-Toalpha documentation | Contained in the Text-Toalpha distribution. |
package Text::Toalpha; use 5.008001; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); our %EXPORT_TAGS = ( 'all' => [ qw(toalpha fromalpha) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw(); our $VERSION = '0.02'; # NOTE: This module is NOT a good example of how to do this kind of task. # Also, the purpose of it is not very apperant. # This code is messy, but I don't know a better way to do this. my @table = ( 'aa' .. 'zz' ); my %out_table; # Build %out_table. Messier. If you are a clean freak, abort now ;-). for (0 .. $#table) { $out_table{$table[$_]} = chr($_); } sub toalpha { my $in = shift; my $out = $in; $out =~ s/(.)/$table[ord($1)]/g; return $out; } sub fromalpha { my $in = shift; my $out = $in; $out =~ s/(..)/$out_table{$1}/eg; return $out; } 1; __END__