If I have the following, how do I get to the members?
$servers = [{'hostname'=>'secure',
'description'=>'www'},
{'hostname'=> 'www3',
'description'=>'www'},
{'hostname'=>'www6',
'description'=>'www'}.
{'hostname'=>'www10',
'description'=>'www'},
{'hostname'=> 'mail',
'description'=>'mail'}];
I used to have a simple list of servers and I would say something like:
foreach $i (@servers)
But now I want to associate more info with each server entry.
So, how can I get my list of servers to iterate over?
Thanks,
Joe 1 1650
Joe McGuckin wrote: If I have the following, how do I get to the members?
$servers = [{'hostname'=>'secure', 'description'=>'www'}, {'hostname'=> 'www3', 'description'=>'www'}, {'hostname'=>'www6', 'description'=>'www'}. {'hostname'=>'www10', 'description'=>'www'}, {'hostname'=> 'mail', 'description'=>'mail'}];
You have a reference to an array of hashes. Assuming that you correct
the typo, you can print them like this:
foreach my $server (@$servers) {
print "Host: $server->{hostname}, Desc: $server->{description}\n";
}
I used to have a simple list of servers and I would say something like:
foreach $i (@servers)
But now I want to associate more info with each server entry.
So, how can I get my list of servers to iterate over?
Read up on arrays of hashes at http://www.perldoc.com/perl5.8.0/pod/perldsc.html
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: fabio de francesco |
last post by:
Hi
what do you think of the following? Why are we permitted to do that?
And why the C++ Library doesn't stop someone willing to perfom that
assignement (*a = 20)?
#include <iostream>
...
|
by: BigMan |
last post by:
Does the C++ standard define what should happen in case of NULL pointer
dereferencing. If not, does it say that it is illegal?
Where, if so, does it say it?
|
by: Vam |
last post by:
dereferencing a pointer to base always provides a base-class slice even if
the object pointed to was of a derived type, correct?
|
by: Dennis Jones |
last post by:
Hello,
Given something like:
boost::shared_ptr<T> t( new T() );
What is the best (correct?) way to dereference the pointer? The following
two methods work. Is there a difference?
|
by: Pushkar Pradhan |
last post by:
I have some functions which take as i/p a buffer (it can be float, char,
or 16 bit, int etc.). The result is another o/p buffer, its type is also
flexible (it could be a float, char etc.).
I try...
|
by: Michael Maes |
last post by:
Hi,
How would I handle Dereferencing in vb.Net 2003.
Something like:
Dim txt As TextBox = DirectCast("txt" & someStringVariable, TextBox)
This sadly won't work because a type of string...
|
by: Martin Jørgensen |
last post by:
Hi,
I have a "funny" question, which I think is pretty "healthy" to
examine... This program is being investigated:
- - - - - - -
#include <iostream>
using namespace std;
#define DAYS 7
|
by: Lutz Richter |
last post by:
Hi,
given the following code:
-----------------------------
class B
{
public:
B(): Value(99) {}
int Get() { if (this) return Value; else return -1; }
|
by: Pritam |
last post by:
line 7: error: dereferencing pointer to incomplete type
1. #include<stdio.h>
2. #include<sys/stat.h>
3. #include<stdlib.h>
4. void execname() {
5. struct task_struct *my;
6. my =...
|
by: prashant.khade1623 |
last post by:
I am not getting the exact idea.
Can you please explain me with an example.
Thanks
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |