Jul 27, 2008

Perl Interactive Mode

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Perl Programming

free web hosting

Perl Interactive Mode

coolcat50
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?

Reply

slu
QUOTE(coolcat50 @ Jan 18 2008, 11:59 PM) *
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:sad.gif-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:



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: http://sourceforge.net/projects/psh/

 

 

 


Reply

coolcat50
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.

CODE
#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);
}

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. interactive - 31.52 hr back. (1)
Similar Topics

Keywords : perl, interactive, mode

  1. Perl As A Way To Program Desktop Applications
    (8)
  2. Where Do I Install Perl Scripts?
    Help, i need somebody help... :P (6)
    Where do i install perl scripts? I couldn't find the path (usr/bin/perl/) and i tried to put one
    script on /home/ /public_html and execute it from a php script, but, nothing happened, the script
    was not working, and yes, the script works properly. The reason for not working is the wrong path i
    suppose.....
  3. What Is Perl ? For A Layman Like Me !
    (7)
    hi, i was wondering what perl was i downloaded Activeperl thinking it is some thing like a CMS lol
    but.... well u know what is it what can you do with it, i really want to know why it is soo famous ?
    hehe thx Scan....
  4. Few Perl Snippets For Misc Things
    (2)
    Convert any number of seconds to days,hours,minutes and seconds. Useful for converting unix time
    differences into days,hours,minutes and seconds. Inputs: ConvertSeconds(no. of seconds) Returns:
    $days,$hours,$minutes,$seconds Assumes: 100% Accurate CODE     
        sub ConvertSeconds {    my $secs=shift;     if($secs<(60*60*24)){
        $days=0;     }     else{     $days=int($secs/(60*60*24));     }
        if((int($secs%60*60*24))<60*60){     $hours....
  5. Call C Code From Perl
    (1)
    I want to call a C routine from Perl program. For this I understand that, I should use XS interface
    language & write some layer between Perl and C. Can anyone tell me the following: 1. What are
    development tools & settings I need to have for this development? 2. What are the steps to carryout
    for developing the interface and connect to Perl? Please note that, I am new to this kind of work.
    However, I have experience on C & to some extent Perl. I am in hurry..please help me. Thanks in
    advance, kvarnerexpress....
  6. Matching Accents In Perl Regular Expresions
    matching accents in perl regular expresi (1)
    Does anyone knows how can i match accents in perl regular expresions. I do not manage to match not
    english characaters such as á, é or ñ. I hope there is someone taht knows the answer because i have
    been searching in google a long time without success. Thanks in advanced....
  7. Xmlhttprequest And Perl
    (2)
    Hi all I've been using XMLHttpRequest with PHP but the time has come where i need the features
    of perl! But i've fallen at the first hurdle.... when using XMLHttpRequest with php you can
    send a response back by using "echo" I cant seem to find a way of sending a response back in perl,
    anyone know of something similar to echo? I've looked through LWP but couldnt find anything
    suitable?? thanks kvarnerexpress....
  8. Compiling Perl / Python?
    is there a way to compile perl/python? (3)
    so im pretty new to programming in general, but these two languages i am even newer to. I'm
    trying to find out if there is a way to compile a perl/python program so that it is encrypted, and
    the source could not be read. or are these languages just scripts? Thanks.....
  9. Perl Interview Questions
    (1)
    Hi, I have to interview a job candidate for a position at my company. I have been put in charge of
    the perl questions. While I know a pretty good amount of perl, I was wondering if any of you could
    provide some good questions (w/ the answers please) that I might be able to ask. Thanks!....
  10. Perl/cgi Help!
    HTML skills required also. (3)
    Im sort of new with perl and I know the basics. Lemme paste the code ... CODE
    #!/usr/bin/perl -w if ($ENV{'REQUEST_METHOD'} eq 'POST') {  
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});   @pairs = split(/&/,
    $buffer);   foreach $pair (@pairs) {   ($name, $value) =
    split(/=/, $pair);   $value =~ tr/+/ /;   $value =~
    s/%([a-fA-F0-9][a-fA-F0-9])<br>/pack("C",
    hex($1))/eg;   &#....
  11. Perl Progamming/scripting
    Insighting discussion on Perl (3)
    Hi there, I like using Perl for programming. Most of the work I do with it eventually involves
    the web. I don't use it in a CGI environment though, I use it as a tier two processing
    language. How do you use perl (if at all), or why do you not like perl vs. your preferred
    language? Thanks, Kristofer Hoch ----------------- "Not a Perl Biggot"....
  12. Easy Authenication With Cgi/perl
    (0)
    I've been thinking for a while about how to authenticate users on my website ... i just wanted
    something simple, maybe cookies are good, etc. I found the following -->
    http://www.cgi101.com/book/ch20/ Not that I need anything super secure, and maybe it's worth
    looking into encrypting the password table in the database, i don't know. it's pretty cool
    though ... enjoy.....
  13. Perl V.s. Php
    PHP vs PERL : Comparision of PHP & PERL (5)
    Now I've always wanted to make a web game. Now I have time. I keep getting suggested both php
    and perl. I know alot about php and stuff. but I hardly know anything about perl .So what would (if
    anything) make perl better than php when programming a web game?....
  14. Using Mysql With Perl
    (1)
    I don't want to learn PHP right now, and I know MySQL can be used with Perl. However, I do not
    know how to use it with Perl at all. I just would like to know how to use it, in a basic script for
    any purpose. I have a Perl book, but it only tells me how to use Perl with the Win32::ODBC Module.
    Could someone please give me a general description of how to use Perl with MySQL? Thanks in
    Advance.....
  15. Perl Programming
    First, Second, .... (0)
    My Second Perl Programm The Simple counter... u must create the file: counter.dat CODE
    #!/usr/bin/perl #counter.cgi urldecode{ local($val)=@_; $val=~s/\+/
    /g;
    $val=~s/%([0-9a-hA-H]{2})/pack('C',hex($1))/ge;
    return $val } $dataf:='couner.dat';
    open(F,"+<$dataf") || die "can't open file counter.dat";
    flock(F,$LOCK_EX); @cnt=<F>; $Dat=@cnt
    $ip=$ENV('REMOTE_ADDR'); ($....
  16. Perl Programms
    First, second, ... (0)
    My 3th Perl Programm The current dir show... CODE #!/usr/local/bin/perl # dir path
    $sdir='.'; opendir(DIR,$sdir) || die "can't opendir
    $some_dir: $!"; @dots = grep {-d "$sdir/$_"}
    readdir(DIR); rewinddir(DIR); @fils = grep {-f "$sdir/$_"}
    readdir(DIR); foreach (@dots){ print "$_\n"; } foreach
    (@fils){ print "$_\n"; } closedir DIR; ....
  17. Second Perl Programm
    Simple counter... (0)
    View all information abaut web host: CODE #!/usr/bin/perl #down.cgi use CGI
    qw(param); use CGI::Carp qw(fatalsToBrowser); print "Content-Type:
    text/html\n\n"; print "<html><body>"; print
    "Script_name: $ENV{'SCRIPT_NAME'}<br>\n"; print
    "S_Full_name: $ENV{'SCRIPT_FILENAME'}<br>\n"; print
    join("<br>",map("$_=$ENV{$_}",keys %ENV));
    print "</body></ht....
  18. First Perl Programm
    My first Perl programm (5)
    I wonna show you my first perl programm: CODE #!/usr/bin/perl # See Log file print
    "Content-type: text/html\n\n"; print
    "<HTML><HEAD><TITLE>Mind of Perl</TITLE>"; print
    "<head><body><p>"; print "<h1>Hay
    Cgi-BIn</h1>"; print "</body></html>" if you have other
    perl script, post it in this topic. How write perl counter?....
  19. Perl And Php
    (7)
    Is perl better than php in any way?....
  20. Perl Help
    How to install modules (1)
    How do I install perl modules??....
  21. Perl
    (4)
    Perl is great to have on your website If you run a message board or chat room ect.......

    1. Looking for perl, interactive, mode

Searching Video's for perl, interactive, mode
advertisement



Perl Interactive Mode



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE