I've run into one of those things where I can't see why my code
fails. ... and know it has to be something obvious.

Why does the second usage of stat... fail in the find() funciton?

#!/usr/local/bin/perl

use strict;
use warnings;
use File::Find;

my $dir2 = './dir2';
my $fname1 = shift;
my ($lastfld) = $fname1 =~ m{^.*/([\w\d\-_]+)$};

my $size = (stat($fname1))[7];
print "$fname1 size: $size\n";
find(
  sub {
    if ($lastfld eq $_) {
      print "<$lastfld> matches <$_>; Lets check the size:\n";
      my $size = (stat($File::Find::name))[7];
      print "$File::Find::name size: $size\n";
    }
  },
   $dir2
);

-------        ---------       ---=---       ---------      --------
./stat ./dir1/sub1/file

output
./dir1/sub1/file size: 10
<file> matches <file>; Lets check the size:
Use of uninitialized value $size in concatenation (.) or string at ./stat line 
23.
./dir2/file size: 




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to