![]() |
|
Perl Monk, Perl Meditation | |
PerlMonks |
Automatic module installationby Juerd (Abbot) |
on May 23, 2002 at 08:03 UTC ( #168693=CUFP: print w/replies, xml ) | Need Help?? |
Let's assume you have a recent Perl and CPANPLUS installed. You want your brand new script to automatically install any modules that are not found. Well, maybe you don't. I'm sure I don't, but I couldn't resist the temptation and made Blah.pm. The module name describes exactly what it does, or... no it doesn't... but I needed a name. My first try had a $SIG{__DIE__} handler and die "Try again :)\n", but it still didn't look nice. I did this because you cannot resurrect scripts. Kane had the idea of using exec($^X, $0, @ARGV) instead, which worked perfectly. But then, lathos suggested using a code ref in @INC. With the help of this node, I created this:
Blah.pmPlease note that real programmers don't use CPANPLUS but CPANPLUS::Backend, and use the great backend. I was lazy and used CPANPLUS with the simple install() function, but that is bad. Example script:
Example output:
Back to
Cool Uses for Perl
|
|