[Pdx-pm] Converting a monolithic program to mvc

benh ben.hengst at gmail.com
Thu Jun 10 12:01:33 PDT 2010

As Jeff and I found out last night you can create 'globals' (see
below), it's not the cleanest thing that I've ever done but it works.

package one;
use two;

$main::globalvar = { hello => 'Phred' };

my $two = two->new;

package two;
print 'Hello ', $main::globalvar->{hello};

2010/6/10 Phred Bob <phredbob at hotmail.com>:
> Hi All,
> I am trying to take a monolithic perl program (approx. 97k lines long) and
> separate concerns (kind of an MVC-style division). I used AutoSplit to break
> out the subroutines, but now I'm stuck. I tried separating the *.al
> subroutines into a View directory if they contained a print statement and
> into a Model directory if they didn't. The main part of the program (before
> __END__) is about 4.6k lines that I am tentatively making the Controller.
> So -- the autoload works as long as the the files are left in the state in
> which were originally generated (a bunch of .al files all in one directory).
> That still leaves me with about 191 separate files with no classification on
> them, so I'd like to organize them in further subdirectories to correspond
> with my separation of them into models, views, and a controller.
> The problem is, if I move them, my autoload function no longer works. And if
> I do put them in a subdirectory and load them as modules, they use their own
> namespace and ignore all the lovely global variables the original developer
> put in his vast, monolithic script.
> Does anyone have any ideas on how to proceed?
> Thanks,
> Fred Lowe
> phredbob at hotmail.com
> ________________________________
> The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with
> Hotmail. Get busy.
> _______________________________________________
> Pdx-pm-list mailing list
> Pdx-pm-list at pm.org
> http://mail.pm.org/mailman/listinfo/pdx-pm-list



More information about the Pdx-pm-list mailing list