Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: Super simple progress

by bigal_george (Acolyte)
on Dec 30, 2019 at 22:04 UTC ( #11110784=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11110784]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2020-07-06 21:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?