Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Re: Re: International Perl Resources

by boo_radley (Parson)
on Jan 31, 2001 at 01:38 UTC ( [id://55366] : note . print w/replies, xml ) Need Help??

in reply to Re: Re: International Perl Resources
in thread International Perl Resources

That'd be an interesting thing to see :
utilisez le franšais ou mourez;

Replies are listed 'Best First'.
Re: Re: Re: Re: International Perl Resources
by mirod (Canon) on Jan 31, 2001 at 03:22 UTC

    Easy, you can write this (from the Camel 3 p. 280):

    #!/bin/perl -P #include "./francais.h" utilise strict; utilise Data::Dumper; mon %hdh; # mes, ma and mon are all like my tant_que (<>) { suivant sauf_si( r/^(.*?):\e*//); # r -> remplacer \e -> espace mon FFqui=FF1; # I do not have the Euro sign on m +y # keyboard so I used F(rench) F(ra +nc) pour mon FFchamp( separe) { mes( FFclef, FFvaleur)= separe /=/, FFchamp; FFhdh{FFqui}{FFclef}= FFvaleur; } } imprime Dumper( %hdh);

    Of course you need a francais.h file

    #define utilise use #define mon my #define ma my #define mes my #define tant_que while #define sauf_si unless #define separe split #define suivant next #define imprime print #define ouvre open #define meurt die #define pour for #define ou or #define execute() \ while( <DATA>) \ { $programme .= $_; } \ $programme=~ s{FF}{\$}g; \ $programme=~ s{r/}{s/}g; \ $programme=~ s{\\e}{\\s}g; \ eval( $programme) or die $@; execute(); __DATA__

    And then you can run it using an input file such as:

    pierreafeux: mari=frederic ami=barnabe femme=wilma animal_de_companie= +dino simpson: mari=omer femme=marjorie enfant=barthelemie dupont: mari=jean femme=marie enfant=pierre animal_de_companie=me +dor

    You will need to make this file executable, or run it with perl -P as you can't do just perl <file> and have the -P on the command line take-over properly.

    And I know it is not robust, especially the quick hacks to French-ize the regexp, ask Damian if you want a real French module!

    Update: I removed the display of the program and moved the execute(); call to the included file, it looks better now.