#!/usr/bin/perl -T use strict; use warnings; #use diagnostics; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); # Clean up our UNIX environment # for more infor read perldoc perlsec $ENV{'PATH'} = '/awiopt/radio:/tmp'; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Flush the output buffer $|++; my @text; # shuffle function from List::Util sub shuffle (@) { my @a=\(@_); my $n; my $i=@_; map { $n = rand($i--); (${$a[$n]}, $a[$n] = $a[$i])[0]; } @_; } print header; print start_html(-title=>"Fun with Typoglycemia", -BGCOLOR=>"#cccc99" ), "\n"; print "
\n"; print h3("Fun", "With", "Typoglycemia"),"\n"; print "
\n"; print hr,"\n"; print "\n\n\n\n"; print "\n \n \n"; print "\n"; print "
Typoglycemic Text
\n"; if ( defined (param('TEXT')) ) { # $/=undef; @text=param('TEXT'); for (@text) { my $line = $_; my $line_copy = $line; while ($line =~ m/(\w+)/g) { next if length($1) < 4; my $start_offset = pos($line) - length($1) +1; my $word_middle_length = length($1) - 2; # force two character lead-in and lead-out if ($word_middle_length > 4) { $word_middle_length -= 2; $start_offset++; } my $word_middle = substr($line, $start_offset, $word_middle_length); my $shuffled_word_middle = join('', shuffle( split(//, $word_middle) ) ); substr($line_copy, $start_offset, $word_middle_length) = $shuffled_word_middle; } print "$line_copy\n"; } } print "
\n"; print br,br; print "\n\n\n\n"; print "\n \n \n"; print "
Enter your text
\n"; print br,br; print start_form; print "
\n"; print textarea('TEXT',"", 15, 80), "\n",br; print submit; print end_form; print "
\n",br; print "\n\n\n\n"; print "\n \n \n"; print "
\n",br; print end_html;