{
my @tab;
sub teledecode {
my $tocode = $_[0];
my @telecode = ();
my $i = 0;
foreach my $byte ( split //, $tocode ) {
$telecode[$i] = $telear[$byte];
$i++;
}
@tab = ();
return arrangecode( "", 0, @telecode );
}
sub arrangecode {
my ( $first, $i, @dat ) = @_;
foreach my $j ( @{ $dat[$i] } ) {
if ( $i < ( @dat - 1 ) ) {
@tab = arrangecode( $first . $j, $i + 1, @dat );
}
# I thnk it is faster written as
# push @tab, $first . $j;
else { $tab[@tab] = $first . $j; }
}
return @tab;
}
}
####
sub teledecode {
@tab = ();
return arrangecode( '', 0, @telear[ split //, $_[0] ] );
}
##
##
foreach my $toto (@ARGV) {
if ( $toto =~ /-d=(\d+)/ ) {
# Perhaps a description of what that slice
# is doing would help the code maintainer :)
print foreach teledecode( @telear[ split //, $1 ] );
}
elsif ( $toto =~ /-s=([a-zA-Z_]+)/ ) {
print smstype($1); # typo fixed by b10m (thanks)
}
else {
print telecode($toto);
}
}
{
my @tab;
sub teledecode {
@tab = ();
return arrangecode( '', 0, @_ );
}
sub arrangecode {
my ( $first, $i, @dat ) = @_;
foreach my $j ( @{ $dat[$i] } ) {
if ( $i < ( @dat - 1 ) ) {
@tab = arrangecode( $first . $j, $i + 1, @dat );
}
else { push @tab, $first . $j; }
}
return @tab;
}
}
##
##
else {
# This slice should probably explained.
print join '', @telealph{ split //, uc( $toto ) };
}