An interactive interpreter/shell?

R

robb

Hi,

Is there a shell out there that has functionality like Python's
interactive interpreter? I've seen references to a few things out
there (two different projects named psh?) But they don't look like
they're currently being worked on, or are up to date.

Thanks,
Robb
 
U

Uri Guttman

ro> Cute response, but OT.

again, you are very wrong. that is an actual perl shell. you can type
perl commands on a line and they get executed. does a shell do much more
than that? do you even understand what that command does?

uri
 
R

robb

Michele said:
...I see that you mention yourself psh and others pointed you to
perl-{based,oriented} *command* shells, but since you talked about
"Python's interactive interpreter" I thought that the closest thing
would have been an... interactive Perl interpreter, which is what I
pointed you to. If you do not find that satisfying, care to say why?

Yes, you're right. I'm sorry about the sarcastic reply earlier.
Here's a description of a few things that the perl interpreter doesn't
do interactively:

http://dev.perl.org/perl6/rfc/184.html

The Python interpreter offers a lot more, though. As a Python
developer, I'm used to being able to start the interpreter, instantiate
some of my new classes I've written, invoke methods, determine the
types of the objects.

The Python interpreter feels a lot like Smalltalk without the graphic
interface.

It's a common development style for Python programmers, and I was
hoping to use it with my Perl development. Here's an example of what I
mean. I'd love to find an environment that provides this kind of
convenient syntax (uses only the syntax of the language itself), plus
has these useful features in Perl. Automatic evaluation of names,
high-level user feedback, etc:
.... def bark(self):
.... print "Woof"
....['__add__', '__class__', '__contains__', '__delattr__', '__doc__',
'__eq__', '__ge__', '__getattribute__', '__getitem__',
'__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__',
'__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__',
'__rmul__', '__setattr__', '__str__', 'capitalize', 'center', 'count',
'decode', 'encode', 'endswith', 'expandtabs', 'find', 'index',
'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle',
'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind',
'rindex', 'rjust', 'rsplit', 'rstrip', 'split', 'splitlines',
'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper',
'zfill']<type 'builtin_function_or_method'>
 
R

robb

...As a Python
developer, I'm used to being able to start the interpreter, instantiate
some of my new classes I've written, invoke methods, determine the
types of the objects.

And, I didn't get too far using the perl interpreter. Maybe I did
something wrong? But also - it's not clear to me that this kind of
work is supported:

DB<1> print "hello\n";
DB<2> use lib '/home/web/lib/perl';
DB<3> use Trillium::Info;
DB<4> my $info = Trillium::Info->new();
DB<5> $info;

DB<6> $info->is_valid_tld('lclark.edu');
Can't call method "is_valid_tld" on an undefined value at (eval
21)[/usr/local/lib/perl5/5.8.0/perl5db.pl:17] line 2.

DB<7> print $info;

DB<8>
 
T

thisisbradley

And, I didn't get too far using the perl interpreter. Maybe I did
something wrong? But also - it's not clear to me that this kind of
work is supported:

DB<1> print "hello\n";
DB<2> use lib '/home/web/lib/perl';
DB<3> use Trillium::Info;
DB<4> my $info = Trillium::Info->new();
DB<5> $info;

DB<6> $info->is_valid_tld('lclark.edu');
Can't call method "is_valid_tld" on an undefined value at (eval
21)[/usr/local/lib/perl5/5.8.0/perl5db.pl:17] line 2.

Try it without the 'my':

M:\>perl -de42
Default die handler restored.

Loading DB routines from perl5db.pl version 1.07
Editor support available.

Enter h or `h h' for help, or `perldoc perldebug' for more help.

main::(-e:1): 42
DB<1> use CGI

DB<2> $x = CGI->new

DB<3> x $x
0 CGI=HASH(0x1af3d28)
'.charset' => 'ISO-8859-1'
'.fieldnames' => HASH(0x1ad0378)
empty hash
'.parameters' => ARRAY(0x19b90f0)
empty array
DB<4> my $y = CGI->new

DB<5> x $y
0 undef
DB<6>


Bradley
 
T

thisisbradley

Mumia said:
I've found "my" to be tricky in the perl debugger. The variable is
probably trapped in an invisible, inaccessible block.

perldebug says:

Any command not recognized by the debugger is directly executed
(eval'd) as Perl code in the current package.

So when using the debugger interactively, lexically scoped variables do
not propogate across multiple statements.
By itself, "$info;" is a useless statement; you probably meant "print
$info;"

Given that $info is an instance of Trillium::Info, I'd probably use 'x
$info' to recursively pretty-print its values. 'print' only outputs
the package name and its memory address.
Without warnings enabled, attempts to print undefined values display
nothing.

Strangely, I only receive a warning when turning on warnings via
'-wde42':

X:\S60>perl -de42
Default die handler restored.

Loading DB routines from perl5db.pl version 1.07
Editor support available.

Enter h or `h h' for help, or `perldoc perldebug' for more help.

main::(-e:1): 42
DB<1> use warnings;

DB<2> print $e

DB<3>

Bradley
 
B

Brian Raven

Michele Dondi said:
Err, well, yes: it's a debugger and not an actual interpreter,
although it offers much of the functionality of the latter. It has
some commands and stuff that is not a command gets eval()'d in the
context of the current package. So you may still write basically any
amount of code you like provided it's all on one line.

See the section on multiline commands in 'perldoc
perldebug'. Essentially, newlines can be escaped with '\'.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,654
Latest member
LannySinge

Latest Threads

Top