Way back in 1999 I gave my very first conference presentation at the first YAPC in Pittsburgh. The title was "Ineffective Perl Programming" and it drew as its material from the many, many, many awful books on Perl out at the time and the ridiculous example code therein. I spent many days in bookstores trolling through pages and pages of "programming by the pound" tomes.
Sometimes in my investigations I'd discover some gems that would provide me with endless material. PI, a "Package Installer for Perl" is one I've just discovered. It's "a simple manager for Perl binary packages". The docs tout, "it doesn't require any external modules, like XML parser or MakeMaker". Well this will be feat. Ok, let's look at that pi.pl the docs talk about.
Hmm... no pi.pl. But there's pi.sh. What's in there?
#!/bin/bash
# Perl Package Installer - prototype shell implementation
compare_versions () { perl -l -- - "$@" << 'END'
sub compare_versions { my $a = shift || 0; my $b = shift || 0;
...and so on... }
print compare_versions(@ARGV); END
newversion=`perl -MFile::Spec -MExtUtils::MM -le ' my $modfile = $ARGV[0]; foreach my $dir (@INC) { my $p = File::Spec->catfile($dir, $modfile); if (-r $p) { $version = MM->parse_version($p); last; } } print $version;' "$modfile"`
# Load Perl configuration eval `perl -V:.*`
That's right folks, let's prototype Perl programs using bash! Why would you inflict such a thing on the world?... Yes, shell functions which contain Perl functions which are then fed to perl and the result pulled back into the shell function and spat back out.... But sometimes there's shell code that shells out to perl!
If you like that, you should see the guts of MakeMaker sometime.
Re:Irony
Aristotle on 2007-09-23T22:15:04
I think it was Schwern himself who said that MakeMaker needs to die.
Re:Irony
chromatic on 2007-09-23T23:51:38
Heh. I was in the room for that, more than once.