Michael G Schwern <[EMAIL PROTECTED]> writes:
>So here's a
>simple solution:
>
> my $m = sprintf <<'MAKE_TEXT', $pod2html_exe, $self->{MAKEFILE};
>POD2HTML_EXE = %s
>POD2HTML = \$(PERLRUN) -we "use File::Basename; use File::Path qw(mkpath);" \\
>-e "%%m=@ARGV;while (($p,$h) = each %%m){" \\
>-e " next if -e $$h && -M $$h < -M $$p && -M $$h < -M '%s';" \\
>-e " print qq(Htmlifying $$h\n);" \\
>-e " $$dir = dirname($$h); mkpath($$dir) unless -d $$dir;" \\
>-e " system(q[$(PERLRUN) $(POD2HTML_EXE) ].qq[$$p > $$h])==0 " \\
>-e " or warn qq(Couldn\\047t install $$h\n);" \\
>-e " chmod(oct($(PERM_RW))), $$h " \\
>-e " or warn qq(chmod $(PERM_RW) $$h: $$!\n);" \\
>-e "}"
>MAKE_TEXT
>
>because there are so few interpolated variables, and so few hashes
>used inside, you can get away with sprintf + a here-doc. The result
>is something that looks a lot more like the final result:
Is creating a script which captures all those -e s out of the question?
It is only a matter of time before enhancements or a user with
a long $dir is going to overflow command line limit (1024?) on Win32.
>
>I also cleaned up the formatting. Even though the program is a series
>of -e's, its now layed out more like normal Perl code.
>
>The $$m{$$_}'s and $$_ have been eliminated in favor of named
>arguments which, while short, at least hint at what they hold ($p for
>POD, $h for HTML). And $$p is much easier to read than $$m{$$_}.
>
>The "$^X -I$(PERL_ARCHLIB) -I$(PERL_LIB)..." is replaced by the
>$(PERLRUN) macro which figures that out for you.
>
>Finally, I noticed that MM_Win32->htmlifypods is exactly the same as
>MM_Unix->htmlifypods except the Unix one uses -e '...' and the Win32
>one uses -e "...". Given how silly it is to override a method just
>because of a quote, I'll just fix up the MM_Unix one to be cross
>platform and throw out the MM_Win32 duplicate.
>
>I suspect there's a lot more of this sort of thing floating around.
--
Nick Ing-Simmons
http://www.ni-s.u-net.com/