psh

Martin, David MARTINDT at eetcorp.com
Thu Aug 23 12:38:09 CDT 2001


here is a script I found (and modified) from the Panther book.  it's not
really a shell like the other thing, but you can run it like a program and
not have to remember the incantaion. This thing really should prompt at the
end to save to a file, just never got around to it.


------------------%<----------------- snip!
#!/usr/bin/perl
# based on eval.pl from Advanced PERL Programming pg 73
# 1/22/1999 - perl prompt instead of eval
# 6/17/1998 - regurgitates command list at exit
# 5/ 7/1998 - multi-line monkey
$Revision = "8/7/1998";

print "$]\n";
print "$0 Rev.$Revision\t\tDTM\n";
print "just type 'quit' to end.\n\n";
undef $Revision;
unshift(@INC,"/usr/local/perl");
print "Contents of \@INC:\n";
print join("\n", @INC);
print "\n";

print "perl: >";
while ( defined ( $s = <> ) ) {
	$result = eval $s;
	last if ( $s =~ m/^quit/i );
	last if ( $s =~ m/^exit/i );
	# enhancements
	if( $s =~ m/^help/i ){ print "\texit or quit to end.\n"; next; }
	elsif( $s =~ m/^hist/i ){ &Rememberies; next; }

	if ( $@ ) {
		print "Invalid string:\n $s";
	}
	else {
			$commandnumber++;
			push( @listocommands, "$commandnumber\t$s\n" );
			print $result, "\n";
			print "perl: >";
	}
}
&Rememberies;
exit 0;

sub Rememberies {
print "List of Commands\n";
print @listocommands;
}
------------------%<----------------- snip!

there is another one; this one runs the perl debugger with no script
attached:
 shell> perl -de 0;
this one is sometimes better than the script version because it will
pretty-print nested hashes.

> David Martin
> EET Corp
> martindt at eetcorp.com
> 865.671.7800
> www.eetcorp.com
> 
-- To the tune of "Yellow Submarine"
"In the town where I was born
lived a man who wrote in C
And he told us of his life
in the land of subroutines..."

http://knoxville.pm.org/




More information about the Knoxville-pm mailing list