in reply to Re: passing argument to sub wanted
in thread passing argument to sub wanted
UPDATE
Mirod's idea does not retain my $size_input and I am still having to hard-code the value. Any more ideas greatly appreciated!
UPDATE AGNsub wanted; File::Find::find({wanted => sub { wanted( $size_input ); } }, $fs_inpu +t ) ;
I changed the find code to include a dereference (->) and the value is being printed the line b4 the int -s, but now the array is not being populated with $name when it should contain 16 elements. Finally when I print *name with $size_input it does not print, but when I print *name with the hard-coded number in the int ((( -s line, I see *name incrementing.
File::Find::find({wanted => sub { wanted->( $size_input ); } }, $fs_i +nput ) ; <snip> else { my ( $size_input ) = shift @_ ; ###-- Freeze the arg --# my ($dev,$ino,$mode,$nlink,$uid,$gid); (( $dev,$ino,$mode,$nlink,$uid,$gid ) = lstat($_) ) && ( $dev >= 0 ) && !( $File::Find::prune |= ($dev != $File::Find::topdev ) ) && print "MIDDLE SZINPT:\t",($size_input),"\n", && ( int(((-s _) + 1023) / 1024 ) > $size_input ) && push ((@large_files), $name); } } ###-- End sub --### print scalar @large_files;
__OUTPUT__ MIDDLE SZINPT: 26214400 MIDDLE SZINPT: 26214400 MIDDLE SZINPT: 26214400 0
|
|---|