CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: create a dbm with a hash, that has a key, with 2 values: Edit Log



dunsta
Novice

May 19, 2013, 11:53 PM


Views: 309
create a dbm with a hash, that has a key, with 2 values

Hi

I want to create a dbm that takes input in the form of something like this


Code
my $var={ 
'one' => {
'steve' => 'Steve@steve.com',
'rei' => 'rei@rei.com',
},
'two' =>{
'naomi' => 'naomi@naomi.com',
'rei' => 'rei@rei.com'
},
};


but a dbm takes a %hash, not a $var, so I am not sure how to go about getting the result I want.

Basically, I want to have different groups, and in each group I can have a name value pair.

Thanks for any input.
This is what I have attempted so far:

Code
my(%mailList2, $name, $email, $group); 

dbmopen(%mailList2, "mailingLists",0644) || die "Cannot open DBM: $!";

print "Enter a number: ";
chomp($group=<STDIN>);
print "Enter a name: ";
chomp($name = <STDIN>);
print "Enter an email: ";
chomp($email = <STDIN>);

$mailList2{$group}{$name} .= $email;



(This post was edited by dunsta on May 20, 2013, 2:54 AM)


Edit Log:
Post edited by dunsta (Novice) on May 20, 2013, 2:54 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives