Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!ukc!stc!datlog!torch!igp From: igp@torch.co.uk (Ian Phillipps) Newsgroups: comp.lang.perl Subject: Re: Perl Shell Keywords: psh pshaw Message-ID: <607@torch.co.uk> Date: 12 Jan 90 13:07:28 GMT References: <4723@itivax.iti.org> <6730@jpl-devvax.JPL.NASA.GOV> Organization: Torch Technology Ltd., Cambridge, England Lines: 31 lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: >In article <4723@itivax.iti.org> scs@iti.org (Steve Simmons) writes: >: Just throwing out an idea -- anybody tried using perl as a shell? >Look at the file "perlsh" in the perl distribution directory. Also, Larry doesn't say that you can use the -d option as a perl shell! I find the following quite useful for testing perl out. It's found three bugs in perl so far. :-) I hope you like the default prompt. Could be written better using packages, but I haven't needed to convert it yet. Main problem is that $_ gets smashed by each iteration of the interpreter. Note that by default the result of the last (scalar) expression gets printed; apparently spurious "1"s are the result of successful printing, etc. ------ cut here and hack to taste ---- #!/usr/local/bin/perl eval "exec perl -S $0 $*" if $running_under_some_shell; $Prompt = ' $_: '; $Printing = "\n"; print $Prompt; while() { $Pres = eval $_ . ';'; print $Pres.$Printing if $Printing; print $@; print $Prompt; }