Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Translate the names of the dates using perl

by Tux (Monsignor)
on Feb 17, 2014 at 11:50 UTC ( #1075161=note: print w/ replies, xml ) Need Help??


in reply to Translate the names of the dates using perl

There are quite a lot of tools available to do this in a generic and reliable way from CPAN, but from what you describe, I think this comes close:

my $tgt = "fr_fr"; my %day = ( en_gb => [qw( sunday monday tuesday wednesday thursday friday satu +rday )], fr_fr => [qw( dimanche lundi mardi mercredi jeudi vendredi samedi +)], it_it => [qw( day0 day1 day2 day3 day4 day5 day6 )], ); my %tr = map { lc $day{en_gb}[$_] => $day{$tgt}[$_] } 0..6; my $tr = do { local $" = "|"; qr{\b (@{$day{en_gb}}) \b}i; }; open my $fh, "<:encoding(utf-8)", "db-dates/$src" or die "$src: $!"; while (<$fh>) { s/$tr/$tr{lc $1}/ge; print; }

Enjoy, Have FUN! H.Merijn


Comment on Re: Translate the names of the dates using perl
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2014-08-20 18:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (121 votes), past polls