foreach my $file (@file_list) { code here... } or foreach my $file (@file_list){ code here... } #### #!/usr/bin/perl -w use strict; use File::Find; my $base_dir = "C:/Temp"; my @jpg_files; find(\&collect_jpg_files, $base_dir); print @jpg_files; # for debugging #prints: C:/Temp/test_file.jpg foreach my $jpg_filepath (@jpg_files) { my $log_filepath = $jpg_filepath; $log_filepath =~ s/jpg$/xml/; #... blah .. blah ... } sub collect_jpg_files { return unless (-f); # only real files, not directories return unless (/\.jpg$/); # name ends in .jpg push (@jpg_files, $File::Find::name); }