Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Module::Build and PM_FILTER

by dragonchild (Archbishop)
on Dec 08, 2004 at 14:25 UTC ( #413204=perlquestion: print w/replies, xml ) Need Help??

dragonchild has asked for the wisdom of the Perl Monks concerning the following question:

I want to add Module::Build support to my CPAN distros - I want to do what all the cool kids are doing.

Except, I use PM_FILTER. *hangs head in shame* I know Schwern has unofficially discouraged it, but I (think I) need it. And, nowhere in the POD for Module::Build is there anything that says how to convert PM_FILTER usage.

So, my question goes kinda like this:

  1. Do I really need PM_FILTER?
  2. If I do, how do I mimic it under Module::Build?

For reference, I use PM_FILTER because PDF::Template supports Unicode for all versions of Perl. Pre-5.8, I use Unicode::String for all my string handling. So, in two .pm files, I have code that looks something like

UNI_YES $x -= $str->length * $font_size; UNI_NO $x -= length($str) * $font_size;
My PM_FILTER code looks like
my $pm_filter = $use_unicode ? q{perl -pi -e "s!UNI_YES ! !g;s!UNI_NO !\\#!g"} : q{perl -pi -e "s!UNI_NO ! !g;s!UNI_YES !\\#!g"};

Which works, AFAICT, on every system that PDF::Template has been installed on. (Which, if I'm honest, has only been Unix, Linux, and Cygwin.)

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re: Module::Build and PM_FILTER (lots of ways)
by tye (Sage) on Dec 08, 2004 at 17:07 UTC

    There are lots of other ways to do that type of thing. Switch to one of them.

    You can define a strlen() function that varies depending on version.

    *strlen = $use_unicode ? sub { $_[0]->length() } : sub { length($_[0]) };

    You can do like my XML::Fling (never made suitable for release to CPAN and no longer available for download due to sudden ISP bankruptcy) where I include a template.plx that I do all of the maintenance on. I run template.plx to generate lib/XML/Fling/Array.pm, lib/XML/Fling/String.pm, and lib/XML/Fling/File.pm and just include all of that in the distribution. So the distribution installs normally. You only need to worry about template.plx if you want to make a change to the module and then you just need to remember to run template.plx to apply your changes (just like you need to remember to test before you release).

    So your template.plx would write a lib/PDF/Template/Unicode.pm and lib/PDF/Template/Ascii.pm or whatever and put code that needs templating into the template.plx and require the appropriate PDF::Template::Unicode or PDF::Template::Ascii depending on what is supported.

    - tye        

Re: Module::Build and PM_FILTER
by Matts (Deacon) on Dec 08, 2004 at 15:37 UTC
    I don't quite get it. You want to migrate away from working code because cool kids do things differently?

    I could understand if EU::MM had been deprecated in favour of M::B, but it hasn't been, mostly because EU::MM does its job damn well, and M::B doesn't yet as far as I can tell (depending on your needs of course).

    I guess I just prefer stability over coolness. I must have been working at a big company too long :-)

      It was somewhat tongue-in-cheek. Plus, I want to support both, not migrate from one to the other. :-)

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

        Why? Majority of CPAN modules are written with MakeMaker

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://413204]
Approved by BrowserUk
Front-paged by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2020-05-29 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (170 votes). Check out past polls.

    Notices?