The above, today would be written more naturally, like:
#!/usr/bin/perl -w
{ package Debug;
use warnings; use strict;
our (@ISA,@EXPORT,$DBGOPS);
use mem;
use mem(@ISA=qw(Exporter), @EXPORT=qw( Debug Filename2Fields HaltOnE
+rror);
use Exporter;
use P;
use constant Filename2Fields => 1;
use constant HaltOnError => Filename2Fields << 1;
sub Debug($$;@) { shift & $DBGOPS && Pe shift,@_ }
1};
###################################################
{ package Transcode_plug;
use warnings; use strict;
our (@ISA, @EXPORT);
use mem;
use mem(@ISA=qw(Exporter), @EXPORT=qw( album get_fieldAR_from_filena
+me);
use Exporter;
use Debug;
sub album() {$_[0]->};
sub get_fieldAR_from_filename($) {
Debug(Filename2Fields, "get_fieldAR_from_filename(%s)", $_[0]);
}
1}
#####################################################
package main;
use Transcode_plug;
use P;
P "Main is running";
# Now see that even prototype parsing works properly:
P "OK";
get_fieldAR_from_filename "Foo";
No BEGIN's in sight, and a natural 'use module' syntax the same as one would use them if they were in separate files.
A few other things would be simpler as well, but they aren't in a form to be published yet...
I do learn...
using mem with Exporter as I did above, also exports the prototypes.
May not be perfect, but looks tidier than using BEGIN blocks and the modules have the benefit of being easily put into separate files
with no code changes.
Better?
|