in reply to Use of uninitialized value for file name

When readdir runs out of entries in the directory it returns an undefined value in scalar context.

Update:...but that won't explain why you get an initialization error.

For example

#!/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"; } }
prints

. ..
when testdir is empty, and prints

. .. something.pl Something was seen
when testdir contains the file something.pl.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.