-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mathew Snyder wrote:
> I'm trying to figure out how to use stat.  I have the following code:
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> my @filenames;
> my $processDir = "/usr/bin";
> 
> opendir DH, $processDir or die "cannot open $processDir: $!";
> foreach my $file (sort(readdir DH)){
>         push @filenames, $file;
> }
> closedir DH;
> 
> foreach my $filename (@filenames){
>         next if ($filename =~ /^.$|^..$/);
>         my $mod_time = (stat($filename))[9];
>         print $filename . "\n";
>         print "$mod_time" . "\n";
> }
> 
> print "There are " .  scalar @filenames . " items in the filenames
> array.\n";
> 
> 
> I've put $mod_time on a seperate line to verify that it is, in fact
> causing the error.  The value of $filename prints followed by a newline
> and then the following error:
> 
> Use of uninitialized value in concatenation (.) or string at
> ./fileAccess.pl line 18.
> 
> Is stat() not getting the information from $filename that I'm expecting
> it to?  How do I use it if not the way I'm trying?
> 
> Mathew


I'm thinking that because all I'm doing is reading the filename into the
array through each iteration, I'm not getting all the associated data
that comes with it.  Basically what I need to do, I think, is figure out
how to stat a file and save the filename and the "stat" into a hash.

Mathew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFE468r7cEqtYW7kARAqhfAJ9uIvbsqX53OeEeG6TBItWJUTiN/ACfQ932
K/5AARgTjGyV8GlVxquuSnw=
=8a8N
-----END PGP SIGNATURE-----

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to