Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use strict;
- use Data::Dumper;
- sub build_hash {
- my ($hash, $a1, $a2, $a3) = @_;
- foreach my $test_var (keys %$hash){
- foreach my $arr ($a1, $a2, $a3){
- foreach my $elem (@$arr) {
- if ($test_var eq $elem){
- push @{$hash->{$test_var}}, 1;
- }
- else {
- push @{$hash->{$test_var}}, undef;
- }
- }
- }
- }
- }
- my @a = ('b','c','f');
- my @b = ('a','d');
- my @c = ('c','d','e');
- my %allowed_table = ('a'=>[],'b'=>[], 'c'=>[], 'd'=>[], 'e'=>[],'f'=>[]);
- build_hash( \%allowed_table, \@a, \@b, \@c);
- print Dumper(\%allowed_table);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement