fork download
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. my (%my_big_hash, %my_tiny_hash, @temp_array);
  5. my $group = "west";
  6. @{ $my_big_hash{$group} } = (1534,343,2341,2322,3345,689,3333,4444,5533,3334,5666,6676,3435);
  7. foreach (@{ $my_big_hash{$group} }){
  8. push @temp_array, substr $_, 0,3;
  9. }
  10. my $element = "Location";
  11. my $group2 = "west";
  12.  
  13. #solution below
  14. @{ $my_tiny_hash{$element}{$group2} } = (153,333,667,343,698);
  15. my %hash = map { $_ => 1 } @temp_array;
  16. foreach my $search (@{$my_tiny_hash{'Location'}->{west}}){
  17. if (exists $hash{$search}){
  18. print "$search exists\n";
  19. }
  20. else{
  21. print "$search does not exists\n";
  22. }
  23. }
Success #stdin #stdout 0s 6184KB
stdin
Standard input is empty
stdout
153 exists
333 exists
667 exists
343 exists
698 does not exists