IPstacks has asked for the wisdom of the Perl Monks concerning the following question:
What I am trying to accomplish is I want the output to be Owner: value then E-mail: key for each pair one by one. However when I run this script, it returns the Owner properly, but then it lists out the three keys that I have listed. I have reviewed my books and I'm not sure where I went wrong, can anyone help, please? Thanks much!#!/usr/bin/perl -w use strict; my %email_owners; my @owners; my @addys; %email_owners = ('mike@foo.net' => 'Mike Foo', 'jwtheis@smic.net' => 'Jim Theis', 'happy@bobbarker.net' => 'Happy Gilmore'); @owners = values (%email_owners); @addys = keys (%email_owners); foreach (@owners) { print "Owner: $_\n"; foreach (@addys) { print "E-mail: $_\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: First time using hashes
by broquaint (Abbot) on Apr 01, 2003 at 14:50 UTC | |
|
Re: First time using hashes
by jasonk (Parson) on Apr 01, 2003 at 14:52 UTC | |
|
Re: First time using hashes
by Aragorn (Curate) on Apr 01, 2003 at 14:58 UTC | |
|
Re: First time using hashes
by Trimbach (Curate) on Apr 01, 2003 at 14:56 UTC | |
|
Re: First time using hashes
by IPstacks (Novice) on Apr 01, 2003 at 14:53 UTC |