Elliot Holden wrote: > this is my hash below: > > > my %dept_and_names = ("Accounting", "John Montgomery", > "Customer Service", "Carol Jefferson", > "Customer Service", "Jill Paulo", > "Research and Development", "Jeffrey Johnson", > "Accounting", "Sam Rantini", > "Payroll", "Susan Choi", > "Research and Development", "LaChonda Washington", > "Customer Service", "Nancy Smith");
Hash keys are unique so creating a hash like that will mean that only the last unique key and its value will be saved resulting in the hash: my %dept_and_names = ( 'Accounting', 'Sam Rantini', 'Payroll', 'Susan Choi', 'Research and Development', 'LaChonda Washington', 'Customer Service', 'Nancy Smith', ); > can someone please suggest a simple way of displaying all of my unique > hash values. For example: I want to display all the names (values) that > have the "Accounting" key, or all the names that have the "Payroll" key. > this is my script below but it only displays the name (value) for each > unique key. It sounds like you need a Hash of Arrays: my %dept_and_names = ( 'Accounting', [ 'John Montgomery', 'Sam Rantini' ], 'Customer Service', [ 'Carol Jefferson', 'Jill Paulo', 'Nancy Smith' ], 'Research and Development', [ 'Jeffrey Johnson', 'LaChonda Washington' ], 'Payroll', [ 'Susan Choi' ], ); for my $dept ( keys %dept_and_names ) { print "$dept: @{$dept_and_names{$dept}}\n"; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>