#!/usr/bin/perl use strict; use warnings; use File::Find; my $sum; sub process { return if -d; return unless /\.p(l|m)$/; my ($res) = `wc -l $_`; $sum += ($res =~ /(\d+)/)[0]; } find(\&process, "."); print $sum . "\n"