in reply to searching for values in hashes
The following illustrates this
#! /usr/bin/perl use strict; use warnings; my @array = qw (one two three four five); my %hash = (one => 'Extra information for one', two => 'Extra information for two'); foreach my $id (@array) { if (exists $hash{$id}) { print "ID: $id has extra info: $hash{$id}\n"; } else { print "ID: $id has no extra info\n"; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: searching for values in hashes
by aukjan (Friar) on Aug 05, 2005 at 11:08 UTC |