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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Question about Array of Hash referance.


New User

Apr 19, 2015, 10:55 AM

Post #1 of 2 (3055 views)
Question about Array of Hash referance. Can't Post

Hello, i'm new to perl programming and i'm trying to make a script where I catch netstat output. I have a hash = {'protocol' => $1, 'Local Adress' => $2 etc etc}. I then use regex to fetch all the information I need from netstat and the protocol in netstat will be the first match and so it will be stored in $1.

I also use a reference like this my $hash_ref = \%hash;

I do this for each line in netstat, once a hash is filled I push it into an Array. Like this push (@Array, \%hash)

My question is how do I print a specified key from a hash in a specifed position in the array?

If I print like this: print $Array[0]
I just get a Hash reference.

I would like to print $Array[0]'key in hash' and get the value.

Is it possible?

Thank you in advance.


Apr 19, 2015, 3:21 PM

Post #2 of 2 (3032 views)
Re: [moshimo] Question about Array of Hash referance. [In reply to] Can't Post


# or cleaner...


This is called dereferencing.


(This post was edited by Zhris on Apr 19, 2015, 3:21 PM)


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

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