Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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?
[LanX]: choroba: GREAT JOKE! xD
LanX starts googling the punch line ...
[choroba]: suddenly, a weird noise can be heard, and the conductor stops them
[choroba]: (sorry, was interrupted by a call)
[choroba]: What was that? asks he
[choroba]: and the triangle player says, "That was me. It's written here in the score"
[choroba]: and shows a bar with a note "ohne Triangel"
[choroba]: where "ohne" means "will bend" in Czech

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2017-03-27 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (319 votes). Check out past polls.