use Net::FTP; # subclass Net::FTP, as well as Net::FTP::A which is # the class of the data connection object. { package My::Net::FTP::A; use base qw( Net::FTP::A ); # override the "read" method: sub read { my $self = shift; my $r = $self->SUPER::read( @_ ); ## ## This is where you can put your custom code. ## E.g. just print out the running total: ## print STDERR "read ", $self->bytes_read, " bytes so far.\n"; ## $r } package My::Net::FTP; use base qw( Net::FTP ); # override the "retr" method: sub retr { my $self = shift; bless $self->SUPER::retr( @_ ), 'My::Net::FTP::A' } } # when you make your Net::FTP object, make it from # your own subclass instead (in this case, My::Net::FTP) - my $ftp = My::Net::FTP->new( "ftp.archive.net", BlockSize => 512, # very useful parameter! ); # and use it: $ftp->login( 'user', 'passwd' ); $ftp->get( $file ); $ftp->quit;