Using -MO=Deparse won't really help. Anyone interested in providing an analysis?
#!/usr/bin/perl -w
%ENV = qw(
bin 42 perl 52 my 33 opt 26 lib 32 site 25 tmp 34
usr 22 var 62 local 36 other 44 misc 12 temp 45
);
@INC = (
"./opt/usr/usr/tmp/opt",
"/perl/lib/usr/usr/72",
"/perl/lib/usr/tmp/bin",
"/usr/misc/lib/usr/var/lib",
"/my/54/other/bin",
"./tmp/lib/usr/tmp/opt/misc/usr/opt/site",
"/usr/usr/23/misc/usr/usr/lib/lib/usr/usr/var/usr",
"/opt/usr/13/usr/usr/lib/local/24/temp",
"/usr/usr/usr/usr/usr/usr/lib/lib/usr/usr/var/usr",
"/usr/usr/usr/usr/tmp/bin/lib/usr/opt/usr/usr",
"./site/local/site/lib",
"/usr/usr/usr/var/usr/usr",
"/site/tmp/temp/lib",
"/usr/var/var/usr/usr",
"/usr/66/usr/usr/site",
"./usr/usr/tmp/other/lib/usr/opt/site",
"/usr/usr/usr/usr/usr/usr/usr/misc/lib/var/usr",
"/opt/opt/usr/64/other/temp",
"/usr/usr/usr/usr/usr/usr/usr/misc/lib/var/usr/lib/usr/usr",
"/usr/usr/usr/usr/tmp/lib/usr/opt/usr/usr/lib/usr/usr",
);
map { $, = $_; map { $, =~ s/$_/$ENV{$_}/g } (keys %ENV); $_ = $,} @INC;
map { s,^\.,$/, } @INC; map { $; = 101+int($_/5)+($_>14);
map { s,/(\d)(\d),' 'x$1."\e[$;m".'#'x$2."\e[m",eg } $INC[$_] } (0..19);
@INC = ((join $/,@INC),$/);
eval { require "JAPH" };
die
Set @INC to carefully constructed rubbish.
Convert @INC to print JAPH in big letters using environments set earlier. This seems to use ANSI/terminal control sequences.
Ask to load a module. This will fail so perl will print out @INC now holding the message.
A nice trick would be to leave the real @INC in place in some form so real modules would work but require "JAPH" would give message.
You're correct about not needing the eval. I left that in because it was how I discovered the trick of doing a require followed by die in the first place, when working on code that needs Win32::CONSOLE::ANSI, but only on Windows. When debugging the program by putting die in the middle, I was surprised that it died with the error I had circumvented with the eval. Looking up die, quickly set me straight that the behavior was correct.
Besides the double entendre on "Dying for a Good Japh", I like the irony that the program complains it can't find JAPH in "Just Another Perl Hacker"!
I think there is an implicit "die" in the error that it can't find the module.
No there isn't. If eval is used, taking out die will cause the output to cease appearing. Try it and see...
I guess it depends on what else you are doing. The eval stops the module load fail from dieing. This allows other lines to be added to the program which will run. When the die is hit the JAPH prints.
On Solaris the eval is not needed and the module could be anything.
@ARGV=split//,"/:L";
map{print substr crypt($_,ord pop),2,3}qw"PerlyouC READPIPE provides"
@ARGV=split//,"/:L";
map{print substr crypt($_,ord pop),2,3}qw"PerlyouC READPIPE provides"
...
eval {require "JAPH"};
print "Hello mum!\n";
die
OUTPUT
Hello mum!
Can't locate JAPH in @INC ...
...
) at test.pl line xx
... propagated at test.pl line yy.
perlmonks.org content © perlmonks.org and liverpole, tweetiepooh
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03