How to forbid functions of some package be introduced to the globalname space?

P

Peng Yu

Hi,

File::Copy would introduce 'copy' in the current namespace, which
would result in conflict in the example below. I'm wondering if there
is anyway to forbid 'copy' be introduced in the current namespace.

Thanks,
Peng

#!/usr/bin/perl

use strict;
use warnings;

use File::Copy;

File::Copy::copy('copy.pl', 'some.pl');
copy('copy.pl', 'other.pl');#conflicts with the following subroutine

__END__

#The following function can not be defined as it is conflicted with
File::Copy::copy.
sub copy {
print "in copy\n";
}
 
S

Sherm Pendley

Peng Yu said:
File::Copy would introduce 'copy' in the current namespace, which
would result in conflict in the example below. I'm wondering if there
is anyway to forbid 'copy' be introduced in the current namespace.

Thanks,
Peng

#!/usr/bin/perl

use strict;
use warnings;

use File::Copy;

use File::Copy(); # Empty import list, so nothing is imported

See 'perldoc -f use' for details.

sherm--
 
M

Martijn Lievaart

Hi,

File::Copy would introduce 'copy' in the current namespace, which would
result in conflict in the example below. I'm wondering if there is
anyway to forbid 'copy' be introduced in the current namespace.

Thanks,
Peng

#!/usr/bin/perl

use strict;
use warnings;

use File::Copy;

use File::Copy ();

HTH,
M4
 
J

Jürgen Exner

Sherm Pendley said:
use File::Copy(); # Empty import list, so nothing is imported

See 'perldoc -f use' for details.

Or exclude after the fact with "no", see "perldoc -f no".

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top