Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: variable as hash name

by Athanasius (Chancellor)
on Dec 08, 2012 at 04:43 UTC ( #1007855=note: print w/replies, xml ) Need Help??

in reply to variable as hash name

It can be done using eval even with strict:

14:36 >perl -Mstrict -MData::Dump -wE "my $variable = 'name01'; eval q +q[our %{$variable} = ( valorC => 'value03', valorD => 'value04', );]; + eval qq[our %{$variable}; dd %{$variable},;];" ("valorD", "value04", "valorC", "value03") 14:36 >

Why you’d want to do it is, of course, another question altogether...

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: variable as hash name
by blackzero (Acolyte) on Dec 08, 2012 at 05:51 UTC

    To count the number of times each element is present. But keep in mind each two consecutive elements of a line will be in a 'group' different than the others.

    And I can not know at first how many groups there will be.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007855]
[LanX]: ... and I can get faster to the Dutch PW or French PW ...
LanX ...(by train from Frankfurt)
[LanX]: renting a car could be an option ...
[NodeReaper]: speedboat

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2018-03-19 11:58 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (239 votes). Check out past polls.