THE LACK THEREOF

Perl hashref iteration example

Here is an example of iterating over a nested hashref datastructure in Perl.

$domaindb = {
  'thelackthereof.org' => {
    'owner' => 'brock',
    'services' => {
      'web' => 1,
      'dns' => 0,
      'email' => 1
    }
  },
  'brockwilcox.org' => {
    'owner' => 'awwaiid',
    'services' => {
      'web' => 1,
    }
  }
};

foreach $domain (keys %{$domaindb}) {
  print "Domain: $domain\tOwner: $domaindb->{$domain}->{owner}\n";
}

Which outputs:

Domain: thelackthereof.org      Owner: brock
Domain: brockwilcox.org         Owner: awwaiid

Fun, eh?

Navigation

Blog

https://thelackthereof.org/pics/16px-Feed-icon.svg.png Blog RSS Feed

Tweets


Code

Follow @awwaiid

2017-03-25

2017-03-14

2017-03-12

Wiki Edits

https://thelackthereof.org/pics/16px-Feed-icon.svg.png Wiki RSS Feed

... more changes