Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Translate the names of the dates using perl

by Tux (Canon)
on Feb 17, 2014 at 11:50 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1075161]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 21:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found