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";