bdimych has asked for the wisdom of the Perl Monks concerning the following question:
I do not want "use y" into z.pm
I think, simplest way is to declare global_sub with some blank dummy namespace:~>cat x.pl use y; use z; z_sub(); ~>cat y.pm package y; sub global_sub { print "global_sub working!" } 1 ~>cat z.pm package z; use Exporter 'import'; our @EXPORT = qw(z_sub); sub z_sub { global_sub(); } 1 ~>perl x.pl Undefined subroutine &z::global_sub called at z.pm line 5.
but I just do not like "G::"! Please help~>cat x.pl use y; use z; z_sub(); ~>cat y.pm package y; sub G::global_sub { print "global_sub working!" } 1 ~>cat z.pm package z; use Exporter 'import'; our @EXPORT = qw(z_sub); sub z_sub { G::global_sub(); } 1 ~> perl x.pl global_sub working!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to declare globally visible subroutine like built-in ones ? Is it possible?
by shmem (Chancellor) on Nov 06, 2007 at 12:44 UTC | |
by bdimych (Monk) on Nov 06, 2007 at 13:22 UTC | |
Re: How to declare globally visible subroutine like built-in ones ? Is it possible?
by Anonymous Monk on Nov 06, 2007 at 11:42 UTC | |
by bdimych (Monk) on Nov 06, 2007 at 12:14 UTC | |
by Anonymous Monk on Nov 06, 2007 at 13:00 UTC |
Back to
Seekers of Perl Wisdom