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: Intermediate:
Berkeley DB dynamic reffernece?

 



parsalog
New User

Feb 6, 2010, 4:20 PM

Post #1 of 3 (682 views)
Berkeley DB dynamic reffernece? Can't Post

Greetings my first post here.

I have about 20 Berkley db's that I have created, all hashes , and all named alphabetically %A %B %C %D .

I want to use a foreach loop to pull from a array of the db names
my @table = qw(A B C D);

and I want to do an insert, into the dbs inside the loop dynamically based on the array.

foreach $db(@table) { ....

$$db{"$key"} = "$value" ; # <--- where I am stuck

above syntax does not work tho, can anyone help me with the right way to do this, specifically reference a BDB hash dynamically?

thanks in advanced


7stud
Enthusiast

Feb 6, 2010, 10:58 PM

Post #2 of 3 (668 views)
Re: [parsalog] Berkeley DB dynamic reffernece? [In reply to] Can't Post

Hash of hashes(HoH):

Code
use strict; 
use warnings;
use 5.010;

my %A = qw {a 1 b 2};
my %B = qw {c 3 d 4};
my %C = qw {e 5 f 6};

my %dbs = (
A => \%A,
B => \%B,
C => \%C,
);

for (keys %dbs) {
say keys %{$dbs{$_}}
}

--output:--
ab
ef
cd



(This post was edited by 7stud on Feb 6, 2010, 11:04 PM)


parsalog
New User

Feb 9, 2010, 6:22 PM

Post #3 of 3 (640 views)
Re: [7stud] Berkeley DB dynamic reffernece? [In reply to] Can't Post

thank you , ill give it a try

 
 


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

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