Direct Mode In Perl Interactive Code Execution

| | TrackBacks (0)

A Quick-and-dirty Script for "Direct Mode" in Perl
Interesting little hack.
Ever get annoyed that there's no "direct mode" environment in Perl?

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

About this Entry

This page contains a single entry by klsh published on November 12, 2003 9:52 AM.

Iconoclast To The End: Smashing Windows For Fun And Prophet was the previous entry in this blog.

Perl disk traversal and space usage analysis is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.