On Sun, Jul 22, 2001 at 08:34:18PM -0500, [EMAIL PROTECTED] wrote:
> opendir(DIR, "/etc/") or die "Can't open directory : $!\n";
> my @list = readdir(DIR);
>   for $file(@list) {
>     next if ( -d $file );
>     $info = (stat($file))[7];
>     print "Filename: $file : $info\n";
>   }
> closedir(DIR);
> 
> I am getting:
> Use of uninitialized value in concatenation (.) at ./stat line 14.

You're getting this because the stat failed, so $info is left undefined. 
The warning mentions concatenation because, internally, the string:

    "Filename: $file : $info\n"

is turned into:

    "Filename: " . $file . " : " . $info . "\n"


Your problem stems from a misunderstanding, or overlooking, of what readdir
returns.  The filenames returned from readdir are relative to the directory,
so trying to do a stat on just the filename is likely to return results you
don't expect (either undef, in your case, or stat results for a different
file).  The solution is to either qualify the paths, or chdir to the
directory in question, then opendir "." and process the files as you are.

    
Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to