#!/usr/bin/perl -w use strict; my $total; for ( glob ('/home/a/*.txt') ) { $total++ if ! -d; } print "The total is $total\n";