in reply to Re^2: File types not being picked up by script
in thread File types not being picked up by script

I am not sure exactly what you are trying to do but as has been mentioned File::Find is the right tool for this job. This is some untested code for your pleasure...
use strict; use warnings; use File::Find; my $starting_dir = "put path to dir here"; my $count_dat_png = 0; find(\&wanted, $starting_dir); print "number of dat and png files: $count_dat_png\n"; sub wanted { return if -d ; # skip directories # . and .. are directories # or just leave this out entirely if (-f and ( /\.dat$/i or /\.png$/i)) { #print "$File::Find::name\n"; #full name if you want $count_dat_png++; } }
added: I would read the example and explanation of the module File::Find carefully.

Replies are listed 'Best First'.
Re^4: File types not being picked up by script
by MShoaib (Initiate) on Jul 07, 2025 at 22:03 UTC

    Thank you both for your feedback, greatly appreciated. I will try your suggestions.