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


2018-12-20

2018-12-18

2018-12-13

2018-11-15

Toots (Mastodon)

2018-07-02

2018-06-30

Code

Follow @awwaiid

Wiki Edits

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

... more changes