http://qs321.pair.com?node_id=11110784


in reply to Re^3: Super simple progress
in thread Super simple progress

Dave I wonder if you could help a bit more; I wanted to make the callback for a delete routine. Mine wont active the callback when I try this:
wrap_subs sub {}, 'File::Copy::Recursive::fcopy', 'File::Find::find',\ +&after_dircopy; find { bydepth => 1, no_chdir => 1, wanted => sub { if (!-l && -d _) { #rmdir && print STDERR "\nDeleted: $_\n" or warn "couldn't rmdir direc +tory $_: $!"; rmdir or warn "couldn't rmdir directory $_: $!"; ($_ ne $sourcedir && $_ ne ".") or die "Process completed"; } else { #print STDERR "."; unlink or warn "couldn't unlink file $_: $!"; } } } => $sourcedir;

Replies are listed 'Best First'.
Re^5: Super simple progress
by davido (Cardinal) on Dec 31, 2019 at 06:28 UTC

    You totally changed modules without taking time to understand how the solution I provided works. File::Copy::Recursive isn't even involved in your new solution, so wrapping it is useless. And File::Find already provides a wanted function that you can hook into; you don't need wrap_subs at all.

    A File::Find solution is just a matter of putting print statements in the wanted function that fire off IF the path meets your wanted criteria. I don't have time right now to help you rewrite it, but to that point, please don't rely on me individually to answer your questions; we have a community here. Also keep in mind most of us are here to teach people how to program, not to provide a crutch for avoiding learning to program.


    Dave