Direct Mode In Perl Interactive Code Execution
A Quick-and-dirty Script for "Direct Mode" in Perl
Interesting little hack.
my $count = 0;
my $statement = "";
print "\n> ";
while (<>) {
chomp;
s/([^\$\\])\#.*$/$1/;
while (/{|\(|\[/g) {$count++};
while (/}|\)|\]/g) {$count--};
$statement .= $_;
if (!$count) {
$_ = eval $statement;
print "\n[$_]\n";
if ($@) {print "Error: $@\n"};
$statement = " ";
print "> ";
}
else {
print "$count> ";
}
}
Code by Atanas Banov
0 TrackBacks
Listed below are links to blogs that reference this entry: Direct Mode In Perl Interactive Code Execution.
TrackBack URL for this entry: http://kennethhunt.com/mt/mt-tb.cgi/942