Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.


Perl Module Design For Dummies, or "I didn't know any better"

I have a 2 KLOC monster. I started writing it and it just grew and grew and grew. Now I hate it, which is sad, because I wrote every [REDACTED] word. Before I started working on it, I hadn't done much with Perl's DBI module and I hadn't written much with modules.

jacoby@oz:~/lib$ ls -l
-rw------- 1 jacoby jacoby 60575 2010-01-26 15:25
jacoby@oz:~/lib$ wc
2175 8253 60575
jacoby@oz:~/lib$ grep 'sub ' | wc -l

Now, I'd love to refactor, break it apart into little pieces, but I'm at a loss about how.

It would be fairly easy to break out SecGenTools::FormTools and SecGenTools::RequestTools and the like. That makes seven kinds of sense. The problem is that I don't have use SecGenTools::FormTools ; in the existing code, I just have use SecGenTools::FormTools ; I could imagine line after line like this.

package Dumb ;
use strict ;
use warnings ;
use Dumb::Dumber ;
use Exporter qw(import) ;
our %EXPORT_TAGS = (
'all' => [ qw( my_function ) ] ,
) ;

sub dumb_function {
return Dumb::Dumber::dumb_function( @_ ) ;

1 ;

But that seems fragile and quite stupid.

Is there any way to seemlessly export the functions of Dumb::Dumber from Dumb without explicitly writing wrapper functions within Dumb? Or am I doomed?

No comments:

Post a Comment