# File: fileMany.pl # Title: Read all files from a folder. Use glob # Author: Mihaela Malita # Folder ManyFiles contains 3 files: poem.txt, mary1.txt, mary2.txt # Program will read each file and print it. use strict; # all variables have to be declared with my use warnings; # gives warnings (same as >perl -w file3.pl ) my @filesInFolder; # array with all files in your folder my $folder; # folder name my $filename; # file you are working with my $line; # the line in the file print "Name of the folder (ManyFiles)? "; $folder = ; chop($folder); #read from keyboard $folder = $folder."/*"; # prepare path: ManyFiles/* means all files in folder @filesInFolder = glob($folder); # files from folder in ARRAY! foreach $filename ( @filesInFolder ) { #read and print each file in folder open(IN,'<',$filename); #open file. File is for sure there print "\n---------",$filename,"--------------\n"; while ($line = ) { #reads line by line until End Of File (EOF) print "$line"; } close IN; } exit;