perl5i ☞ perl5g
作者:gugod 發佈於:schwern has this perl5i module that aims to fix as much of Perl 5 as possible in one go. I read it and liked the approach, so I wrote a small program named perl5g
that basically does the same thing, but you can put it in your shbang.
You can find it in my just created bin.git, which is really just about 5% of my ~/bin folder at this moment.
So here's an example program written in perl5g:
#!/usr/bin/env perl5g
for my $module (@ARGV) {
try {
load $module;
say "$module => @{[$module->VERSION]}";
} catch($error) {
say "Failed to load $module: $error";
}
}
It runs like this:
> module-version IO::All CPAN
IO::All => 0.39
CPAN => 1.9304
Since it's now possible to modify perl5 language with Devel::Declare and the related B::*
families, it's actually possible to make Perl5 a little perl6ish-perfect. You can easily craft your own perl5 interpreter like what I did. Checkout the source code, it's actually simple.