On Wednesday 12 February 2003 22:40, Graham Barr wrote: > On Wed, Feb 12, 2003 at 09:54:29PM +0000, Fergal Daly wrote: > > That said I actually think the nicest thing about it is that exporting > > just a couple of symbols can be done in 1 line instead of 4, > > Well with recent perls it can be done in two without the code bloat > > use base qw(Exporter); > our @EXPORT = qw(symbols); True. Looking through the builtin modules I see this over and over again our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS); BEGIN { use Exporter (); @EXPORT = qw(getservbyname getservbyport getservent getserv); @EXPORT_OK = qw( $s_name @s_aliases $s_port $s_proto ); %EXPORT_TAGS = ( FIELDS => [ @EXPORT_OK, @EXPORT ] ); } use vars @EXPORT_OK; the BEGIN is needed for the use vars to work. At the moment User/pwent.pm does this use vars grep /^\$pw_/, @EXPORT_OK; which is not pleasant and I'd guess there's worse to be found elsewhere. This can be replaced with use Exporter::Easy ( EXPORT => [qw(getservbyname getservbyport getservent getserv)], OK => [qw( $s_name @s_aliases $s_port $s_proto )], ALL => 'FIELDS', ); It will automatically do a "use vars" on all the variables that are mentioned on the basis that if you're exporting them they're going to have be somewhere else in your module too. Of course you can turn this off if you want or use tags to select which vars you want to do a "use vars" on. I've started cleaning up the builtin modules and I've written test scripts to check that the same symbols are exported before and after clean up. Should I continue? Would the changes be accepted? F -- Do you need someone with lots of Unix sysadmin and/or lots of OO software development experience? Go on, giz a job. My CV - http://www.fergaldaly.com/cv.htmlThread Previous | Thread Next