[Dbix-class] RFC: Possibly cleaner output for DBIC::Schema::Loader dumps

Brandon Black blblack at gmail.com
Fri Jul 21 18:21:34 CEST 2006


On 7/21/06, Nilson Santos Figueiredo Junior <acid06 at gmail.com> wrote:
> Well, I still think that trying to improve it somehow will at least
> make it an easier task to cleanup. I think the current output is
> pretty sane. I just, honestly, truly, hate __PACKAGE__. It's probably
> the ugliest thing in Perl, IMO. But, of course, this is just a
> personal aesthetic preference. ;-)

I don't really know the history, but I suspect the perl guys got the
idea for it from Standard C's __FILE__ and __LINE__ etc which are used
for debugging/exception messages mostly, to identify the source
file/line the problem occurs in.

I agree though that it shouldn't be something that's used in everyday
code like it is, but that's how it has to be done in perl, and its a
pretty widely understood idiom.

Start mucking about with "$pkg = __PACKAGE__" in code you're
generating for $joe_random_user, and I bet we end up with a bug report
that gets tracked down to the guy changing $pkg halfway down the file
or something, or we get people confused as to why the idiom is being
done differently, and wondering what magic is going on behind the
curtains, etc.  All for a bit of visual improvement.  I say if people
want to do things like this to the output, they're welcome to "perl
-pi -e 's/.../../' *.pm" or whatever.

I would say its probably not a bad idea to throw in a hook for
customizing the output, like a config option "dump_substitutions" that
allows one to specify regexes to transform the output before it hits
the file.  However, while it would be easy to use this from a custom
script which is calling make_schema_at directly, it would be difficult
and ugly to expose this all the way through to myapp_create.pl.

-- Brandon



More information about the Dbix-class mailing list