use strict; # these are sample files from my test directory my @files = qw(testhere.pl closure.pl hello.pl); my $semi_count; foreach my $file (@files) { open FILE, $file or die "Can't open $file: $!\n"; $semi_count += tr /;// for ; close FILE; } print $semi_count;