I have a file with this in it:

a.b = 10
c.d.e = 11
f.g.h.i.j.k = 12

Based on that, I want to set:

$HASH{a}{b} = 10;
$HASH{c}{d}{e} = 11;
$HASH{f}{g}{h}{i}{j}{k} = 12;

This is easy using eval(), but is there a better way?

I realize that entries like "a.b = 10" and "a.b.c = 13" would
conflict, since setting $HASH{a}{b}{c} to 13 automatically sets
$HASH{a}{b} to a hashref. I've confirmed my file has no such conflicts.

This came up when I was looking at the output of snmpwalk. I realize
Perl has lots of modules to handle SNMP, but I was looking to do
something on my own.

-- 
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to