mikejones has asked for the wisdom of the Perl Monks concerning the following question:

Perl people, please help as I have tried numerous times to get this solved. Seems to be failing at
@large_files = grep { -s $_ > '5' } @files;

#!/usr/bin/perl use strict; use warnings; use Carp; use Data::Dumper; my (@files,@large_files); print "\nPlease enter filesystem name in the form of '/fsname'\n"; my $fs = <>; chomp ($fs); opendir(DIR, $fs) or croak "opendir failed: '$fs' $!"; @files = grep { -f "$fs/$_" and /^\.*/ } readdir(DIR); closedir (DIR) or carp "dir '$fs' not closed $!"; print Dumper(@files); print "\n\n\n"; @large_files = grep { -s $_ > '5' } @files; print Dumper(@large_files); exit;

thanks!

Replies are listed 'Best First'.
Re: Use of uninitialized value in numeric gt (>) at find_hog line 21, <> line 1
by Fletch (Bishop) on Dec 14, 2007 at 20:10 UTC

    The file names in @files aren't prefixed with the containing directory $fs so the size test is returning undef.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: Use of uninitialized value in numeric gt (>) at find_hog line 21, <> line 1
by shmem (Chancellor) on Dec 14, 2007 at 23:47 UTC
    What Fletch said - fix:
    @files = map { "$fs/$_" } grep { -f "$fs/$_" and /^\.*/ } readdir(DIR);