Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Translate the names of the dates using perl

by Tux (Abbot)
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

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 browsing the Monastery: (6)
As of 2016-10-01 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (7 votes). Check out past polls.