my $dir = 'input_files'; opendir(DIR, $dir) or die "can't opendir $!"; while (defined(my $file = readdir(DIR))) { # do something with "$dirname/$file" print "The directory and file are $dir/$file\n"; open (IN, "< $dir/$file" ) or die ("Can't open input file $!"); while ( < IN > ){ print ; } } closedir(DIR); #### allergies immunizations #### # Input file for allergies # Date, Diagnosed By, Type, allergy, reaction,specifics
2009-05-16,Children's Hospital Boston,drugs,penicillin,Blue rash,This only happens on weekends
2009-05-17,Boston Medical Group,drugs,Vitamin B,Rash on torso,This happens after 9PM
2009-05-17,Memorial Hospital,food,Diary,Upset stomach and gas, Happens after drinking whole milk
##
## perl create_indivo_schemas.pl Name "main::IN" used only once: possible typo at create_indivo_schemas.pl line 18. The directory and file are input_files/allergies INThe directory and file are input_files/immunizations INThe directory and file are input_files/.. INThe directory and file are input_files/. #### open (my $fh, "< $dir/$file" ) or die ("Can't open input file $!"); while ( < $fh > ){ print ; } #### open (my $fh, "< input_files/immunizations" ) or die ("Can't open input file $!"); #### my @file_list = `ls input_files`; # get the list of files from the input directory foreach (@file_list){ # loop through the files that are in the directory chomp; my $filename = 'input_files/'.$_; print "file name is : $filename\n"; open (my $fh, "< $filename" ) or die ("Can't open input file $!"); open (my $fh, "< $filename" ) or die ("Can't open input file $!"); while ( < $fh > ){ # look through the data in the file print; print "\n"; }