in reply to next if regex matches

As others have already provided you with an answer, I'll provide you with an alternate solution :)
use File::Find::Rule; my @files = find( file => name => [ '*.txt', '*.log' ], in => $your_path_here );
That should find all *.{txt,log} files in the directories in and below $your_path_here and store them as filenames in @files. Ain't File::Find::Rule great folks?
HTH

_________
broquaint