#!/usr/bin/perl use warnings; use strict; use File::Find::Rule; my $dir = "C:/Windows"; my @files = File::Find::Rule ->file() ->name('*.txt') ->mindepth(1) ->maxdepth(1) ->in($dir); print "$_\n" for @files;