Win has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Use of uninitialized value for file name
by wfsp (Abbot) on Apr 13, 2006 at 16:54 UTC
    When I'm stumped I often try reducing the script to the bare bones to get something working and gradually add things back in.

    Something like:

    #!/usr/bin/perl use warnings; use strict; my $dir = 'c:/Perl'; opendir DIR_A, $dir or die $!; while(my $job = readdir(DIR_A)){ print "$job\n"; } __DATA__ ---------- Capture Output ---------- > "C:\Perl\bin\perl.exe" _new.pl . .. bin Desktop.ini eg html lib myperl site Tidy > Terminated with exit code 0.
    When you come up against the error you'll have a better chance of narrowing down the source of your grief.

    Hope that helps.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Use of uninitialized value for file name
by duff (Parson) on Apr 13, 2006 at 16:00 UTC
    It says Use of uninitialized value for $job.

    Are you sure? What is the exact error message? How do you know it's not complaining about $directory_location?

    BTW, there's no need to quote your variables when concatenating them. A simple $directory_location.$job will suffice.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Use of uninitialized value for file name
by moklevat (Priest) on Apr 13, 2006 at 15:59 UTC
    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.
    A reply falls below the community's threshold of quality. You may see it by logging in.