Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

looping in a hashtable

by Ammu (Novice)
on Sep 09, 2012 at 14:12 UTC ( #992588=perlquestion: print w/ replies, xml ) Need Help??
Ammu has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

It would have been a great if someone giv help in d below reaquirement since i am beginner in Perl.

I have a table store_details in database which looks like below

Account Store day E200 ABC 1 E400 EFG 2

I need to store this in a hashtable(But there wont be any key).Next is to iterate through each rows and get corresponding store numbers for each row.I know the query for that.For eg:I need to put ABC in a query and i will get corresponding store numbers .For eg: for ABC store numbers will be 200,300,400.So i need to creat a new hashtable for which i need to give the corresponding values of ABC to all store numbers.For eg:

Account Store day E200 200 1 E200 300 1 E200 400 1

Like that i need to do for the second row in hashtable also.

Here since 200,300,400 is for ABC store,i will be assigning the other columns values fo rABC to 200,300,400.Can any one help me in this??Pleasee..

Comment on looping in a hashtable
Select or Download Code
Re: looping in a hashtable
by NetWallah (Monsignor) on Sep 09, 2012 at 20:01 UTC
    Your problem statements in recent submissions are rather confusing.

    I think the structure you are seeking is a HASH-OF-ARRAYS. Something like this:

    my %Accountinfo; $Accountinfo{E200} = [200, 300, 400]; $Accountinfo{E400} = ["EFG"]; #Now , you can iterate through all stores for all accounts: for my $acct (sort keys %Accountinfo){ for my $store (@{ $Accountinfo{$acct} } ){ print "Account $acct has store $store\n"; } }
    If this is confusing, please study REFERENCES in perl. (perldoc perlref from a command line).

                 I hope life isn't a big joke, because I don't get it.
                       -SNL

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://992588]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-04-21 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (489 votes), past polls