#!/usr/bin/perl use warnings; use strict; opendir(DIR_A, './testdir') or die $!; while (my $job = readdir(DIR_A)) { print "$job\n"; if ($job =~ /something/) { print "Something was seen\n"; } } #### . .. #### . .. something.pl Something was seen