in reply to Re: Re: Create a built-in-like sub?
in thread Create a built-in-like sub?

Just as a note, your module should look like (at least in 5005_03):
package GLOBAL use 'Exporter'; @ISA = qw(Exporter); #not always needed, but usually a good practice @EXPORT = qw(compress); ... 1; package MODULE use GLOBAL; use Exporter; @ISA = qw(Exporter); #again, usually a good practice. @EXPORT = qw(test); sub test { compress "test\n"; } 1;
I may be incorrect in the new perl 5.6+ world since I'm still using 5.005_03. The only reason I added the use statement to the MODULE package is to make sure that the sub compress is pushed into it.

Hope this helps, but YMMV.

Theodore Charles III
Network Administrator
Los Angeles Senior High
4650 W. Olympic Blvd.
Los Angeles, CA 90019
323-937-3210 ext. 224
email->secon_kun@hotmail.com

Replies are listed 'Best First'.
Re: Re: Re: Re: Create a built-in-like sub?
by Juerd (Abbot) on Feb 01, 2002 at 23:45 UTC
    use base is new syntax, introduced with Perl 5.004_04, so it should work with your 5.005_03.
    You have to type less, and the intent is clear immediately.

    It will require the module if needed, and will push it onto @ISA. It will do some other things as well - read the manual.

    2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$