Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: File::Rsync output functions and global variables

by tilly (Archbishop)
on Oct 11, 2003 at 22:44 UTC ( [id://298581]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to File::Rsync output functions and global variables

You can indeed play games with references closures. Here is a solution that does both:
package MyModule; use File::Rsync; # In some local scope my $rsync = File::Rsync->new({ outfun => bind_args(\&capture_messages, \ my $out), errfun => bind_args(\&capture_messages, \ my $err), }); # Somewhere else sub capture_messages { my ($string_ref, $message, $type) = @_; $$string_ref .= $message . "\n"; } sub bind_args { my ($func, @args) = @_; sub {$func->(@args, @_)}; }
A bit sophisticated, but now the output is captured in a variable that is local to wherever your rsync declaration is done.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://298581]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.