in reply to Need Urgent help in perl

I'd recommend Path::Tiny for dealing with files
use Path::Tiny; my $dir = path('/tmp/bkp'); for my $file ($dir->children(qr/\.gz$/)) { say $file; if ($file->exists) { ... } }