Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to write a module function that overrides imported function in perl

I have a question: I want to write a method called "copy" for my module M. This function is a wrapper of the imported function File::Copy::copy. So I have to use File::Copy::copy and define my own copy. But it will have an error saying that copy is redefined. How to achieve my goal?

#M.pm
package M;
use File::Copy;

#... constructor and other methods

sub copy {
  my $self = shift;
  my $target = shift;
  File::Copy::copy($self->{'PATH'},$target);
}
like image 995
Peiti Li Avatar asked Jul 15 '26 02:07

Peiti Li


1 Answers

use File::Copy qw( );  # Don't import anything.
like image 195
ikegami Avatar answered Jul 17 '26 16:07

ikegami