Harry Putnam wrote:
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];
my $size = (stat($_))[7];
print "$File::Find::name size: $size\n";
}
},
$dir2
);
File::Find changes the working directory to each subdirectory as it
processes it. To prevent this, set the no_chdir flag. See `perldoc
File::Find` for details. http://perldoc.perl.org/File/Find.html
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/