in reply to Interactive Perl Interpreter
The above needs some improvement, for example, eval is not as powerful as perl -e. A bigger challenge by far for a serious 'perl shell' would be to provide the advanced features, e.g. inline editing, history recall/substitution etc., that are available for e.g. ksh, so that the fledgling perl shell competes well enough with established shells.use strict; use warnings; do { print ">>> "; my $cmd = <>; my $status = eval $cmd; $status or Syntax($cmd); } while 1; sub Syntax { print STDERR "Error parsing $_[0]"; }
Update In case anyone wonders, the loop exits when the user enters 'exit', because eval 'exit' does indeed exit the interpreting program.
-M
Free your mind
|
|---|