Dermot wrote:
2009/11/13 Subhashini <subhashinibasavar...@gmail.com>:

I am doing a coversion on french to english words.I have installed the
dictionary and i could use it on my command prompt using the following
command.

dict -d fd-fra-eng bonjour   This is a french to english coversion

dict -d fd-eng-fra potato    This is an english to french coversion

I want to run this using perl and display the translation onto an output
file

I could give you the quick and dirty answer but 1) you'd not learn
anything apart from that 2) I'd be flamed if I let didn't make a few
comment about your script.

Here is my piece of code

#!/usr/bin/perl

It's always a good idea to enable warning and the strict pragam. This
give you valuable feedback about what's not right with your script.

#!/usr/bin/perl

use warnings;
use strict;


print "ENTER THE WORD IN ENGLISH";
print "\n";
$english=<STDIN>;

You will have a trailing new line from that <STDIN>. You want to get
rid of that because you dict programme is not going to store words
with a "\n" at the end of each term and hence the lookup will fail.
Use chomp() to remove these new line characters.

my $english = chomp(<STDIN>);

chomp() returns the *number* of newlines that were removed:

chomp( my $english = <STDIN> );




John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to