use Hook::LexWrap; use File::Copy::Recursive qw(dircopy); use strict; use vars qw($dir_from $dir_to); $dir_from = "/tmp/from"; $dir_to = "/tmp/to"; $|=1; # Using Hook::LexWrap my @dirs; wrap *File::Copy::Recursive::copy, pre => sub { @dirs = @_ }, post => sub { printf "copying %s to %s. \r", @dirs }; dircopy($dir_from, $dir_to); print "\n"; #### use File::Copy::Recursive qw(dircopy); use strict; use vars qw($dir_from $dir_to *mycopy); $dir_from = "/tmp/from"; $dir_to = "/tmp/to"; sub mycopy_func { # call the original &mycopy(@_); # call my sub after mycopy_showprogress(@_); } sub mycopy_showprogress { # this could call anything to show progress or even # to operate on the file being copied printf "copying %s to %s. \r",@_; } $|=1; # Add the hook *mycopy = *File::Copy::Recursive::copy; *File::Copy::Recursive::copy = *mycopy_func; dircopy($dir_from, $dir_to); print "\n";