Saturday, July 16, 2022

[FIXED] How to handle subroutine redefined errors in Perl

Issue

So I have a file that in short has this problem...

#!/usr/bin/perl -w
package Foo;

use strict;
use POSIX;

...

sub remove {
  ...
}
...

and I get a get an error saying the subroutine remove has been redefined. I know the problem, there is a subroutine called remove in POSIX. However, I don't know how to handle it. How is this problem typically solved?


Solution

do this:

use POSIX ();

which will stop the export all default functionality of the POSIX module. You will then need to prefix all POSIX methods with POSIX:: such as:

POSIX::remove(filename)

for the POSIX remove function.



Answered By - ennuikiller
Answer Checked By - Gilberto Lyons (PHPFixing Admin)

No comments:

Post a Comment

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