Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^2: Localizing hash keys in an AoH

by kennethk (Abbot)
on Mar 15, 2013 at 21:05 UTC ( #1023778=note: print w/replies, xml ) Need Help??

in reply to Re: Localizing hash keys in an AoH
in thread Localizing hash keys in an AoH

So string eval works so long as the entire trailing code block is in the string, which gets pretty clunky for one scenario I'm dealing with. But it works, which is better than I've gotten on my own.
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @data = ( {unit => 'S', value => 50, }, {unit => 'T', value => 60, }, {unit => 'Q', value => 70, }, ); LOCAL_BLOCK: { my $cmd; $cmd .= "local \$data[$_]{unit} = 'S';\n" for 0 .. $#data; $cmd .= 'print Dumper \@data'; eval $cmd; } print Dumper \@data;

I'll do some digging on the cited modules, to see if they work in my context.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1023778]
[Corion]: TCLion: Whee ;)
[TCLion]: need to put like this : 2017-02-20 09:30:53
[1nickt]: That's why I asked if you are using DateTime. It has a large number of supporting modules (the author likes the term 'eco-system') so if you are already creating a DateTime obj from your dates, this module would read in the mnoron-formatted 1s seamlessly
[TCLion]: when I put the date together it looks like : 2017-Feb-24 (month is the problem)
[1nickt]: good luck, then.
[TCLion]: looking at DateTime documentation in monastery now

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-03-23 14:57 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (288 votes). Check out past polls.