in reply to There are errors in this JAPH );
This JAPH is lovely, but I haven't a Perl environment in which it works as written. Here's a bit of analysis and a fix which makes it work on my system.
just another Perl e,
And in Windows, under both ActivePerl and Strawberry, I get:
just Perl hack,
as per jdalbec's comment.
The problem under Linux seems to be that:
fails with:perl -WTe "my $b=0;$b->d();" 2>&1
rather than the desired:syntax error at -e line 1, near "my ="
This can be fixed by changing the double quotes to single quotes, in the declaration of @z, making $z[3] be:Can't call method "d" without a package or object reference at -e line + 1.
With this change, the output becomes:'\'my $b=0;$b->d();\'');
It seems to my fairly vague understanding that this was the intended output, given the code posted. Here's a version which (although a little verbose for a JAPH), on my Linux system, prints just another Perl hacker,. I haven't worked one out for the Windows side.just another Perl hack,
I can't say I'm sure why it is that the double quotes are causing so much trouble. It seems to me that the $b inside a double quoted string literal is being translated as the value of $b and thus the code being run is actually:@z=('"my %h;1 if defined(%h);"','"my %h=(c=>0);*ENV=\\%h;system(\'echo + $ENV{c}\');"','"require v9;"','\'my $b=0;$b->d();\'');$s=sub{($c,$p) +=@_;$c='perl -WTe '.$c.' 2>&1';$e=`$c`;@w=split/ /,$e;$w[$p]};%l=(0,9 +,1,4,2,0,3,[4,6]);$\=' ';print $m=&$s($z[$_],$l{$_})for(0..2);undef $ +\;$o='';$o.=&$s($z[3],$l{3}[$_])for(0..1);@o=$o=~/./g;print $o[3],@o[ +8..10];@o=$m=~/./g;print @o[1..2];$o=&$s($z[2],5);@o=$o=~/./g;print $ +o[-1];
Which (obviously) causes a syntax error. Am I interpreting correctly? Edit: Indeed, I am interpreting correctly, now that I re-read jdalbec's earlier post.my undef=0;undef->d();
|
|---|