PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, November 25, 2022

[FIXED] how to write a module function that overrides imported function in perl

 November 25, 2022     module, perl, subroutine     No comments   

Issue

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);
}

Solution

use File::Copy qw( );  # Don't import anything.


Answered By - ikegami
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing