GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Multi Dimensional Array + Perl
Operating System - HP-UX
1847177
Members
5353
Online
110263
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2007 05:19 PM
04-19-2007 05:19 PM
Multi Dimensional Array + Perl
Hi,
I have an issue. I am using perl and oracle to retrieve data. Thing is that After retrieving data from database i have to do certain checks with other values and for that i have to pivk the value from multidimensinal array.
E.g:
i have a array as [xyz 24 India]
[abc 26 USA]
[def 42 Aus]
here first column is Name second is Age and third is Place
and i want to retrieve corresponding age of xyz or say def address.
SO what i am doing is i am connecting to database thru perl and from there i will get a list of files with there status , size , date
so in that i want to pick the date which may be at 2 or 3rd column and then size according to conditions. Hope you understand so if any one can let me know how to do with example as how to retrieve data from Mutlidimesional array.
I have an issue. I am using perl and oracle to retrieve data. Thing is that After retrieving data from database i have to do certain checks with other values and for that i have to pivk the value from multidimensinal array.
E.g:
i have a array as [xyz 24 India]
[abc 26 USA]
[def 42 Aus]
here first column is Name second is Age and third is Place
and i want to retrieve corresponding age of xyz or say def address.
SO what i am doing is i am connecting to database thru perl and from there i will get a list of files with there status , size , date
so in that i want to pick the date which may be at 2 or 3rd column and then size according to conditions. Hope you understand so if any one can let me know how to do with example as how to retrieve data from Mutlidimesional array.
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2007 06:40 PM
04-19-2007 06:40 PM
Re: Multi Dimensional Array + Perl
If the data gets more complicated I don't know if multidimansional arrays (LOL: Lists Of Lists) is the right way to deal with it.
If e.g. the "name" is unique accross the columns, you're far better of with a hash of hashes (HOH) (easy to convert BTW)
my @lol = (
[qw( xyz 24 India )],
[qw( abc 26 USA )],
[qw( def 42 Aus )],
);
1. Using the LOL
my $name;
my $sth = $dbh->prepare ("select name from foo");
$sth->execute ();
$sth->bind_columns (\$name);
while ($sth->fetch) {
foreach my $n (@lol) {
$n->[0] eq $name or next;
print "Found $name.",
" Age = ", $_->[1],
" Location = ", $_->[2],
"\n";
last;
}
}
2. Using a HOH
my %hoh = map {
$_->[0] => {
age => $_->[1],
loc => $_->[2],
}
} @lol;
my $name;
my $sth = $dbh->prepare ("select name from foo");
$sth->execute ();
$sth->bind_columns (\$name);
while ($sth->fetch) {
exists $hoh{$name} or next;
print "Found $name. Age = $hoh{$name}{age}, Location = $hoh{$name}{loc}\n";
}
Is this what you wanted to know?
Enjoy, Have FUN! H.Merijn
If e.g. the "name" is unique accross the columns, you're far better of with a hash of hashes (HOH) (easy to convert BTW)
my @lol = (
[qw( xyz 24 India )],
[qw( abc 26 USA )],
[qw( def 42 Aus )],
);
1. Using the LOL
my $name;
my $sth = $dbh->prepare ("select name from foo");
$sth->execute ();
$sth->bind_columns (\$name);
while ($sth->fetch) {
foreach my $n (@lol) {
$n->[0] eq $name or next;
print "Found $name.",
" Age = ", $_->[1],
" Location = ", $_->[2],
"\n";
last;
}
}
2. Using a HOH
my %hoh = map {
$_->[0] => {
age => $_->[1],
loc => $_->[2],
}
} @lol;
my $name;
my $sth = $dbh->prepare ("select name from foo");
$sth->execute ();
$sth->bind_columns (\$name);
while ($sth->fetch) {
exists $hoh{$name} or next;
print "Found $name. Age = $hoh{$name}{age}, Location = $hoh{$name}{loc}\n";
}
Is this what you wanted to know?
Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP