Jump to content
xisto Community
Sign in to follow this  
coolcat50

Perl Interactive Mode

Recommended Posts

I am kind of wondering why for some reason, Perl does not have an interactive mode in its parser like Pythong does in its. Also, Python comes pre-packaged with a GUI like parser and it is written in Python\Tk (I think that's what its called). I know that Perl has Perl\Tk, and I know it has an eval function. Why is there no interactive parser like that. I think I could come up with one. Anybody, wanna see if we can build a interactive module like the Python one?

Share this post


Link to post
Share on other sites

I am kind of wondering why for some reason, Perl does not have an interactive mode in its parser like Pythong does in its. Also, Python comes pre-packaged with a GUI like parser and it is written in Python\Tk (I think that's what its called). I know that Perl has Perl\Tk, and I know it has an eval function. Why is there no interactive parser like that. I think I could come up with one. Anybody, wanna see if we can build a interactive module like the Python one?

Several options for interactive mode already exists.

 

Perl has a builtin debugger, that enables you to try code (and scripts) interactively. To get an debugging prompt start Perl like this:

CONSOLE
$ perl -d -e 1

 

Loading DB routines from perl5db.pl version 1.28

Editor support available.

 

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

 

main::)-e:1): 1

DB<1> print "Hello\n";

Hello

 

DB<2> exit;

Debugged program terminated. Use q to quit or R to restart,

use o inhibit_exit to avoid stopping after program termination,

h q, h R or h o to get additional info.

DB<3> q

$

you can read the man pages "man perldebtut" and "man perldebug" or perldebug and perldebtut to learn more.

 

If the debugger isn't your thing, you can try the Perl Console, that seems to be very similar to the Python interactive mode: http://www.sukria.net/perlconsole.html

 

It looks like this:

 

Posted Image

 

Another option is The Perl Shell (psh), which is exactly that: a shell aiming at being a replacement of your favorite shell (i.e. bash). It's a bit different fromt the debugger and console, but you might like it: https://sourceforge.net/projects/psh/

Share this post


Link to post
Share on other sites

I actually came up with a script that does the job exactly. The only thing is that it is command prompt based. I do believe I have a Tk based one that I may post here. I would like to put a script like this onto SourceForge. Here is the command line script. I wrote this under Mac OS X at school.

#pmode.pl: A Perl program designed to act similar to then Python interactive mode#	using the eval() function. It takes input from STDIN and evals it.$i = 5;while($i == 5) {	print "Perl<< ";	$code=<STDIN>;	eval($code);}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.