Problem: This code only works when I hard-code the size to search for in the routine. I try to pass arguments using @_, but it does not work. How do I pass $size_input so wanted sees and uses it?

thank you in advance!

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; <snip> else { print "USING LAST ELSE\n"; $size_input = ( int 25 * ( 1024**2 ) ) ; $size_input =~ tr /\000//d ; sub wanted ; File::Find::find({wanted => \&wanted}, $fs_input ) ;

###-- Tried and does not work => File::Find::find({wanted => \&want +ed}, $fs_input, $size_input ) ; --### } sub wanted { ( $fs_input ) = shift @_ ; print "FSINPT:\t",$fs_input,"\n"; for my $key ( sort keys %mounts ) { if ( $fs_input eq $key ) { @mounts = grep {$fs_input} @{ $mounts{$key} } ; } } ###-- End For my key --### if ( scalar @mounts > 0 ) { die "To bad, your dead", join( ":", @mounts ), "\n\nI said your dead $!" ; } else { ( $size_input ) = shift @_ ; my ($dev,$ino,$mode,$nlink,$uid,$gid); (( $dev,$ino,$mode,$nlink,$uid,$gid ) = lstat($_) ) && ( $dev >= 0 ) && !( $File::Find::prune |= ($dev != $File::Find::topdev ) ) && ( int(((-s _) + 1023) / 1024 ) > 26367 ) && ###-- only works when a hard-coded value is used --###

###-- ( int(((-s _) + 1023) / 1024 ) > $size_input )--### ###-- GET ERROR if $size_input is used: Use of ###-- uninitialized value in numeric gt (>) push ((@large_files), $name); } } ###-- End sub --### print scalar @large_files; print join("\n",@large_files); exit; <snip>

In reply to passing argument to sub wanted by mikejones

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.