I read the "Why I hate File::Find..." three times and adjusted my code and it seems to retain the var $size_input yet my array it not being populated. When I hard-code the number in, my array is populated as expected. I am almost begging for help b/c I cannot understand how to solve this anymore or what add'l tools to use other than Dumper and perl -d.

Please help on this frustrating code. Thank you in advance!

<snip> use strict; use warnings; my ( @root_files, @large_files, %mounts, @mounts, ) ; use vars qw/*name *dir *prune/ ; *name = *File::Find::name ; *dir = *File::Find::dir ; *prune = *File::Find::prune ; <snip> } else { print "USING LAST ELSE\n"; my $size_input = ( int 25 * ( 1024**2 ) ) ; $size_input =~ tr /\000//d ; my $wanted = make_wanted ( \&wanted_1, $size_input ) ; File::Find::find( $wanted, $fs_input ) ; print "\n"; } sub wanted_1 { for my $key ( sort keys %mounts ) { if ( $fs_input eq $key ) { @mounts = grep {$fs_input} @{ $mounts{$key} } ; ###-- HoA --### } } if ( scalar @mounts > 0 ) { die "cant search...foobarbazzzzy $!" ; } else { my ( $size_input ) = shift @_ ; print $size_input,"\n"; 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 ) > $size_input ) && push ((@large_files), $name ) ; } } sub make_wanted { my $wanted = shift ; # get the "real" wanted function my @args = @_ ; # "freeze" the arguments my $sub = sub { $wanted->( @args ); } ; # generate the anon sub return $sub ; # return it } print "\n",scalar @large_files,"\n"; exit; <snip>

$size_input is being printed correctly/accurately, but nothing in the array.


In reply to Re^2: passing argument to sub wanted by mikejones
in thread 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.