perl v5.10.1 -- vish
On 27 July 2011 13:59:11 UTC+1, Avishalom Shalit <[email protected]> wrote: > head file | perl -MData::Dumper -wple 'BEGIN{use strict;my %t=(); my > @months=qw(jan feb mar apr may jun jul aug sep oct nov dec);@t{map > uc,@months}=1..12;$a=\%t;} ; s/(?<=\d\d-)(...)(?=-\d\d)/$t{"$1"}/;' > > fails (specifically JUN is replaced with an empty string) > > $ head -2 U__E__103.tsv | perl -MData::Dumper -wple 'BEGIN{use strict;my > %t=(); my @months=qw(jan feb mar apr may jun jul aug sep oct nov dec);@t{map > uc,@months}=1..12;$a=\%t;} ; s/(?<=\d\d-)(...)(?=-\d\d)/$a->{"$1"}/;' > > works > > > -- vish > > > > > > On 27 July 2011 12:55, Gaal Yahas <[email protected]> wrote: >> Please paste the command you're trying. Hash subscript works for me. >> $ perl -le '%t = (a => "b", c => "d"); print $t{a}' >> b >> On Wed, Jul 27, 2011 at 2:05 PM, Avishalom Shalit <[email protected]> >> wrote: >>> >>> to reiterate the problem >>> >>> $t{something} >>> is interpreted as ($t) ({something}) >>> >>> in a one liner >>> >>> (not in a script) >>> -- vish >>> >> >> -- >> Gaal Yahas <[email protected]> >> http://gaal.livejournal.com/ >> >> _______________________________________________ >> Perl mailing list >> [email protected] >> http://mail.perl.org.il/mailman/listinfo/perl >> > > _______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
