Take this Data structure (which is an anonymous hash)
#
# $bears = {
#
#
# rec0 => {
# name => 'sweaterie',
# type => 'sweater',
# color => 'golden brown',
# food => 'mixed berries',
# }, # ect
# };
I am trying to build from a flat file dynamically:
# the text file looks like:
# name1|type|color|food
# name2|type|color|food
open (DATA, "bear_data.txt") || die "Could not access file $!";
local $/; # undefine the builtin var $/
$tmp = <DATA>;
@tmp = split (/\n/,$tmp);
my $n = 0;
my $bears = {};
foreach $line (@tmp){
my ($name,$type,$color,$food); # is this correct?
($name,$type,$color,$food) = split (/|/, $line);
$bears->{"rec$n"} = {};
# problem here #
$bears->{"rec$n"}{
name => $name;
type => $type;
color => $color;
food => $food;
};
$n++;
}
Please point out what I missed or if there is a better way of accomplishing this,
Thanks,
Dave
--------------------------------------------
Looking for Web Talent, You found it!
portfolio: www.coraconnection.com/web/
email: [EMAIL PROTECTED]
tel/fax: (860) 231-9988
--------------------------------------------
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]