Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Data::Dumper;
  4.  
  5. sub build_hash {
  6. my ($hash, $a1, $a2, $a3) = @_;
  7. foreach my $test_var (keys %$hash){
  8. foreach my $arr ($a1, $a2, $a3){
  9. foreach my $elem (@$arr) {
  10. if ($test_var eq $elem){
  11. push @{$hash->{$test_var}}, 1;
  12. }
  13. else {
  14. push @{$hash->{$test_var}}, undef;
  15. }
  16. }
  17. }
  18. }
  19. }
  20.  
  21. my @a = ('b','c','f');
  22. my @b = ('a','d');
  23. my @c = ('c','d','e');
  24.  
  25. my %allowed_table = ('a'=>[],'b'=>[], 'c'=>[], 'd'=>[], 'e'=>[],'f'=>[]);
  26. build_hash( \%allowed_table, \@a, \@b, \@c);
  27. print Dumper(\%allowed_table);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement