use strict; use warnings; use Data::Dumper; my $total_count; my %files = map {$_, 0} glob "./s*.pl"; for my $key (keys %files) { my $count = getcount($key); $files{$key} = $count; $total_count += $count; } sub getcount { local @ARGV = @_; while (<>) {}; return $.; } print Dumper \%files; print "Total size = $total_count lines.\n"; #### $ perl line_count.pl $VAR1 = { './sum.pl' => '19', './summary.pl' => '16', './strict.pl' => '15', './schwartz2.pl' => '13', './sort_hash.pl' => '12', './separat.pl' => '28', './subdiscard3.pl' => '12', './schwartz.pl' => '27', './subdiscard2.pl' => '54', './scope.pl' => '16', './serv.pl' => '28', './shuffle.pl' => '21', './subdiscard.pl' => '23' }; total size = 284 lines. #### use strict; use warnings; my $total_count; my @files = glob "./s*.pl"; for my $file (@files) { my $count = getcount($file); print "$file \t $count \n"; $total_count += $count; } sub getcount { local @ARGV = @_; while (<>) {}; return $.; } print "Total size = $total_count lines.\n"; #### $ perl line_count.pl ./schwartz.pl 27 ./schwartz2.pl 13 ./scope.pl 16 ./separat.pl 28 ./serv.pl 28 ./shuffle.pl 21 ./summary.pl 16 ./sort_hash.pl 12 ./strict.pl 15 ./subdiscard.pl 23 ./subdiscard2.pl 54 ./subdiscard3.pl 12 ./sum.pl 19 Total size = 284 lines.