# version 1.0 use warnings; use strict; use Shell; my %function = ( allergies => sub { funct( "hello" ) }, immunizations => sub { print "in immunizations\n" }, ); my $dir = 'input_files'; die "can't opendir $!" unless opendir DIR, $dir; while (defined(my $file = readdir DIR)) { do { # print "The directory and file are $dir/$file\n"; die "Can't open input file $!" unless open IN, "< $dir/$file"; use File::Glob (); while (defined($_ = glob(' IN '))) { # print "Hello $_"; } while (){ # Reading contents of file next if (/^#/); $function{$file}->() if exists $function{$file}; # print "Bye " . $_ ; } }; } closedir DIR; sub funct{ my ($temp) = @_; print "$temp\n"; } #### hello hello hello in immunizations