in reply to Re^3: An Unreal Perl Hacker!
in thread An Unreal Perl Hacker!

Sure. Suppose noob comes up to his screen with a program that isn't working right:
#!/usr/bin/perl for ($i=0,$i<=5,$i++) { print "FOO\n"; }
which prints:
FOO FOO FOO
no matter what he does. (classic newbie mistake that used to bug me when I was doing C :) He checks a box that says "output is incorrect."

Our critter will extract the for() loop from his code, and wrap it in :
eval { for (i=0,$i<=5,$i++) { print "FOO\n"; } }; print "'$@'";
This tells our critter that the code did execute. It's next step is to examine node replies for similar code fragments. Pretty soon (!), it discovers that a for() loop should have ';' instead of ',' as iterator separators, and hands back the code:
#!/usr/bin/perl for ($i=0;$i<=5;$i++) { print "FOO\n"; }
A further refinement would have it make a scope declaration pass, and hand back:
#!/usr/bin/perl use strict; use warnings; for (my $i=0;$i<=5;$i++) { print "FOO\n"; }

Replies are listed 'Best First'.
Re^5: An Unreal Perl Hacker!
by pajout (Curate) on Oct 14, 2005 at 13:35 UTC
    Thanks for reply, good idea, I keep it in mind for my week-end contemplations :) Specially, how much complicated code could be (succesively) processed by this way, and, if this can be effective with a small set of categorized context (
    my $current_context = ['syntax error','unexpected warning','unexpected + output','neverending loop'];
    )
      I think the goal here should be to figure out something that can help in some cases, and then expand the scope of {some}.