Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Swalif

by Swalif (Scribe)
on May 09, 2009 at 15:00 UTC ( #763044=user: print w/replies, xml ) Need Help??

#!/usr/bin/perl use strict; use CGI; use Encode; use utf8; my $cgi = new CGI; print $cgi->header(-charset=>'UTF-8'), $cgi->start_html ( -title=>'Annotated Translator', -bgcolor=>'lightyellow' ), $cgi->center, $cgi->h1('Annotated Translator V0.1'), $cgi->hr; print "
"; my $input = "ali cat arabic"; my @list = split ' ', $input; my $long; while(my $element=shift(@list)) { print $element; my $test = toArabic($element); if ($test eq "No matches"){ $long.=" $element"; } else{ $long.=" $element"; } } sub toArabic { my $word = shift; $word =~ s/^\s+//; $word =~ s/\s+$//; $word = ucfirst lc $word; my $char = lc substr( $word, 0, 1 ); my $file = "dict/" . $char . "_words.txt"; my %dict; open(my $fh, '<:encoding(UTF-8)', $file) or die "Could not open file '$file' $!"; while (my $row = <$fh>) { chomp $row; my @list = split ':', $row; $dict{$list[0]} = $list1 ;} if (exists $dict{$word}) { my $result = $dict{$word}; return $result; } else { return "No matches"; } } print $long; $cgi->end_html;

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2018-04-23 21:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?