This script emulates a (really ugly) perl shell within your bash (or wathever) session. I like it to quickly test a few regexps or a function.
-
#!/usr/bin/perl -wn
-
-
# the -n switch gives us a loop around the script. the BEGIN block is
-
# only executed once. it sets up our prompt and turns off the signals
-
# that could interrupt the script
-
-
BEGIN {
-
# turn off control keys
-
$SIG{$_} = 'IGNORE' for keys %SIG;
-
# let the user know how to get off this crazy thing.
-
print "\n\tType\e[1m exit\e[0m when you are ready to stop.\n";
-
-
$history = 1;
-
sub prompt {
-
print "\n", $ENV{USER}, '@perl-shell[', $history++, ']>';
-
}
-
prompt;
-
}
-
# the body is executed over and over (each time <> is given). all we
-
# do is eval the body, and voila, perl-shell behavior
-
-
eval;
-
$@ and warn $@; # give perl errors back to the user
-
-
prompt; # print a fresh prompt with updated history
-
-
END { print "\n\t\tBye!\n\n" }
thought, on 04/May/04 at 12:15 am # :
FirstPost
(au cas ou)
thought, on 08/Jun/04 at 7:55 pm # :
and the source of the code: http://sedition.com/perl/perl-shell.html.
commented, on 08/Jun/04 at 11:23 pm # :
Ho nice, I got it via a friend on IRC but couldnt tell where it was from. Are you the author of this script ? If so, good job, it helped me a few times
commented, on 08/Sep/04 at 9:56 pm # :
hey, there, Ozh. back after awhile. it's sort of mine, i got the original idea/skeleton from tim maher who was running the seattle perl users group.