Tuna has asked for the wisdom of the Perl Monks concerning the following question:
My problem is that each file that I open contains some identical data. So, I wind up pushing duplicate key/value pairs into the hash of arrays. How can I avoid this, so I only end up with unique key/value pairs?foreach $file(@list_of_files) { open FILE, "$dir/$$file" || die "Can't open $dir/$file: $!\n"; while ($lines = <FILE>) { chomp $lines; next if ($lines =~ /unknown|shutdown/); ($name, $ranks, $serial_numbers) = split(' ',$line); push @{$HoL{$name}}, $ranks; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to remove duplicate key/value pairs in hash of array
by chipmunk (Parson) on Feb 20, 2001 at 23:09 UTC | |
by Tuna (Friar) on Feb 21, 2001 at 03:06 UTC | |
by chipmunk (Parson) on Feb 21, 2001 at 03:33 UTC | |
|
Re: How to remove duplicate key/value pairs in hash of array
by dws (Chancellor) on Feb 20, 2001 at 23:20 UTC | |
by bdalzell (Sexton) on Feb 04, 2009 at 15:18 UTC | |
|
Re: How to remove duplicate key/value pairs in hash of array
by dfog (Scribe) on Feb 20, 2001 at 23:14 UTC | |
|
Re: How to remove duplicate key/value pairs in hash of array
by hbm (Hermit) on Feb 04, 2009 at 16:56 UTC |