internal package
Foswiki::Util::MuteOut use Foswiki::Util::MuteOut; sub proc { my ($dir) = @_; my $rc = system "ls -la $dir"; print STDERR "RC=", $rc; } my $mute = Foswiki::Util::MuteOut->new; # Nothing will be displayed by proc() $mute->exec(\&proc, "/etc");Capture output into files:
my $capture = Foswiki::Util::MuteOut->new( outFile => 'stdout.txt', errFile => 'stderr.txt', ); # The output will end up in corresponding files. $capture->exec(\&proc, "/etc");