Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Use of uninitialized value for file name

by wfsp (Abbot)
on Apr 13, 2006 at 16:54 UTC ( #543151=note: print w/replies, xml ) Need Help??

in reply to Use of uninitialized value for file name

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" . .. 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.

Replies are listed 'Best First'.
Re^2: Use of uninitialized value for file name
by Win (Novice) on Apr 13, 2006 at 17:59 UTC
    Thanks, I followed your advice and then realised that I was doing multiple whiles and forgetting to close file handles. Basic error I'm afraid.

      Had you been using lexical handles as it must have certainly been suggested to you (at least I *think* I did and I'm *confident* others did too), and properly scoped blocks, which should be natural in any case, then you wouldn't have needed explicit closes and you would have avoided this annoying error.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://543151]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2018-01-20 18:13 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (227 votes). Check out past polls.