in reply to passing argument to sub wanted

Hi,
update:checking File::Find, I now think that find(\%options, @directories); is more what you should try to do...

you need to pass it as a parameter to the wanted() call like:
#!/usr/bin/perl use strict; use warnings; use File::Find; use vars qw/*name *dir *prune/ ; *name = *File::Find::name ; *dir = *File::Find::dir ; *prune = *File::Find::prune ; my $size_input; my $fs_input = '/tmp'; $size_input = ( int 25 * ( 1024**2 ) ) ; $size_input =~ tr /\000//d ; sub wanted ; File::Find::find({wanted => \&wanted($size_input)}, $fs_input ) ; sub wanted { my ($size_input ) = @_ ; print "FSINPT:\t",$fs_input,"\n"; print "SizeINPT:\t",$size_input,"\n"; return; } ###-- End sub --###
at least returns the following:
FSINPT: /tmp SizeINPT: 26214400 Odd number of elements in anonymous hash at 686513.pl line 17. Use of uninitialized value in subroutine entry at /usr/share/perl/5.8/ +File/Find.pm line 822. Can't use string ("") as a subroutine ref while "strict refs" in use a +t /usr/share/perl/5.8/File/Find.pm line 822.
so the size parameter has been "accepted" by wanted.

Regards,
svenXY

Replies are listed 'Best First'.
Re^2: passing argument to sub wanted
by ikegami (Patriarch) on May 14, 2008 at 14:29 UTC
    \&wanted($size_input) doesn't work at all. It calls wanted then and there, and returns a reference to the result returned by wanted.