#!/usr/bin/perl -w use strict; my $dir = 'C:\Users\ZB\Desktop\Text Files'; opendir (DIR, $dir) or die "cannot opendir $dir"; foreach my $file (readdir(DIR)) { &process_file ($file); } sub process_file { my $line = @_; my @array = split(/ /, $line); print "$#array\n"; } closedir (DIR);