[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] MacPerl cmd line?




Andreas Marcel Riechert wrote in repsonse to Vicki Brown:

> You don't want to distribute it via ftp etc.? This applications
> sounds very interesting. 
> 
> >If you need more, Rich Morin & I have been woking on a fairly large and
> >complex piece of code that sorta kinda emulates a Unix shell :-)  It wasn't
> >done in time for the book, but I'd be happy to send it along as a fairly
> >complex example!
> >
> >- Vicki

Well here's a tiny one being distributed via SMTP.  It does not emulate 
a unix shell but more of a perl shell.  It was distributed with the perl 
source code years ago, though I think not any more.  As awkward as it is 
I still find it useful for testing perl constructs, but not for regular 
interactive use.  A tip in using it: if pressing return twice does not
eval your code then type a semi-colon followed by two returns:

#!/usr/local/bin/perl

# Poor man's perl shell.

# Simply type two carriage returns every time you want to evaluate.
# Note that it must be a complete perl statement--don't type double
#  carriage return in the middle of a loop.

$/ = "\n\n";    # set paragraph mode
$SHlinesep = "\n";
while ($SHcmd = <>) {
    $/ = $SHlinesep;
    eval $SHcmd; print $@ || "\n";
    $SHlinesep = $/; $/ = '';
}

__END__

Peter Prymmer