LPM: record creation in perl
Kenneth Rogers
neth at dslky.net
Mon Feb 5 20:41:46 CST 2001
I've been trying to puzzle this one out of the cookbook for about half an hour now and I just can't quite get it.
p.383 if you want to follow along.
They've created a record '$record' which is an anonymous hash, they claim to be able to make a hash of these records for use
"#store record
$byname{ $record->{NAME} } = $record; "
So then in order to make a bunch of these does this mean I need to have a $record that's separate for each one that I want to build? I'm hoping not I'm trying to make a dynamic system where I can create these records (the one's I'm using have 4 integers and an array that contains integers and characters right now). The problem I see right now is that I don't know how to just add a new record to '$byname' without completely creating the whole record first, I'd rather be able to say something like
$byname{$record->{NUMBER} } = { NUMBER => 2,
PARENT => 1,
BOARD => @board };
but I can't tell if that's legal ( it doesn't compile but that could be my fault and not that its impossible to do. )
Is there a better way to do this? Maybe a two dimensional array or somesuch, I can't figure out how to get the data I need packed into a 2D array right now though.
anyway, Thanks In Advance.
Ken R.
OS X: Power meets Grace, Unix with a Macintosh face. -- Salon.com
More information about the Lexington-pm
mailing list