Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A hash with only one entry

Status
Not open for further replies.

columb

IS-IT--Management
Joined
Feb 5, 2004
Messages
1,231
Location
EU
I've got some code which builds up a hash of hashes. If all is well then the secondary hash should have two entries, otherwise I need to report the error.

So far my code looks like
Code:
my %users;
# each entry $users{$user} should look like { host1 => uid1, host2 => uid2 }

foreach my $user ( %users )
  {
  if ( scalar keys %{$users{$user}} == 1 )
    {
     print "$user is only registered on one host - ?????\n";
     next;
    }
  }

What should go in the ???? bit please?

Ceci n'est pas une signature
Columb Healy
 
print "$user is only registered on one host - ", keys %{$users{$user}}, "\n";
 
Thanks travs69

The solution, once I saw it, was obvious, but I'd never have got there on my own.

I owe you one.

Ceci n'est pas une signature
Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top