Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Re: Re: International Perl Resources

by mirod (Canon)
on Jan 31, 2001 at 03:22 UTC ( #55392=note: print w/ replies, xml ) Need Help??


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

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.


Comment on Re: Re: Re: Re: International Perl Resources
Select or Download Code
Re: Re: Re: Re: Re: International Perl Resources
by jlawrenc (Scribe) on Mar 25, 2001 at 20:59 UTC
    Brilliance!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://55392]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2014-12-28 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (183 votes), past polls