in reply to Comparing values within a Hash of Arrays

You can't use exists in this case, as you are not looking to see if a hash key exists, you need to check within the array to see if an element exists. Here's an example of what I think you want to achieve:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use List::Util qw( first ); my @array1 = ( "proc1", "proc2", "proc3", "proc4" ); my @array2 = ( "proc1", "proc2", "proc3", "proc4", "proc5" ); my %HoA = ( prebuilds => [@array1], postbuilds => [@array2], ); for my $postbuild ( @{ $HoA{ postbuilds } } ){ print "$postbuild: "; if ( first { $_ =~ $postbuild } @{ $HoA{ prebuilds } } ){ print "yes\n"; } else { print "no\n"; } }

Replies are listed 'Best First'.
Re^2: Comparing values within a Hash of Arrays
by TJRandall (Sexton) on Apr 24, 2012 at 14:30 UTC

    Ha! Just saw your edit - did the same, because your direction/suggestion was spot on! Thank you to everyone for replying!

      I just edit it back :) Let me know which way you needed it originally and I'll fix it permanently

        It's correct now - finding postbuild rows against the prebuild list. Thank you again!