in reply to File::Rsync output functions and global variables
If you need to limit the scope further, you can put braces around the code which needs to see it.
package MyModule; use File::Rsync; my $rsync; { my %rsync_out; $rsync=File::Rsync->new( { outfun => &rsync_out, errfun => &rsync_out, } ); sub rsync_out { my ($message, $type)=shift; $rsync_out{$type}.="$message\n"; } sub outmsg { $rsync_out{out} } sub errmsg { $rsync_out{err} } } # ... # code here has no clue about %rsync_out # (but it can still see $rsync because I declared # it outside the braces.) # ... # Access the output using the outmsg and errmsg subs my $output = outmsg;
The code not tested. In most cases, you don't need to bother with this anyway.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: File::Rsync output functions and global variables
by sandfly (Beadle) on Oct 09, 2003 at 07:34 UTC |