#!/usr/bin/perl -w
use strict;
use lib '.';
use MyTest;
my $x = "blah blah blah\n";
chomp($x);
print "^$x\$\n";
####
package MyTest;
use strict;
BEGIN {
use Exporter ();
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(chomp);
}
sub chomp(@) {
my $str = shift;
CORE::chomp($str);
return $str . "_this is a test";
}
1;
##
##
package MyTest;
use strict;
sub import {
*main::chomp = \&MyTest::chomp; # Doesn't work
# *::chomp = \&MyTest::chomp; # Doesn't work either
# *CORE::chomp = \&MyTest::chomp; # Nope
# *main::chomp = \*MyTest::chomp; # Sorry, no go
# *::chomp = \*MyTest::chomp; # I wish
# *CORE::chomp = \*MyTest::chomp; # Please, give it up
}
sub chomp($) {
my $str = shift;
CORE::chomp($str);
return $str . "_this is a test";
}
1;
##
##
^blah blah blah$
##
##
^blah blah blah_this is a test$