Acme-Text-Viceversa
view release on metacpan or search on metacpan
lib/Acme/Text/Viceversa.pm view on Meta::CPAN
package Acme::Text::Viceversa;
use 5.008001;
use strict;
use warnings;
use Carp;
use utf8;
our $VERSION = "0.07";
sub new {
my $class = shift;
return bless {}, $class;
}
my %ascii = (
q' ' => ' ', # same!
lib/Acme/Text/Viceversa.pm view on Meta::CPAN
sub ÇÊÉÊoɹ {
my $self = shift;
my $str = shift;
croak $self->ÇÊÉÊoɹ( __PACKAGE__ . " accepts only ascii and their upset." )
unless $str =~ /^(:?[ -~$list]+)$/o;
my @results = ();
my $string = '';
my $buffer = '';
while ( $string = substr( $str, 0, 1, '' ) or $string eq '0' ){
# some charactors have length 2 even if they were under utf8
if( exists $rot180{$string} ) {
unshift @results, $rot180{$string};
$buffer = '';
}else{
$buffer .= $string;
next unless exists $rot180{$buffer};
unshift @results, $rot180{$buffer};
$buffer = '';
}
}
( run in 0.519 second using v1.01-cache-2.11-cpan-49f99fa48dc )