Professional Web Applications Themes

using perl interpreter interactively like python? - PERL Beginners

I'd like to open perl and execute a few commands interactively in the console. I learn a lot in python this way, and I need to understand some perl code. Did this kind of thing ever get added to perl?...

  1. #1

    Default using perl interpreter interactively like python?

    I'd like to open perl and execute a few commands interactively in the
    console. I learn a lot in python this way, and I need to understand some
    perl code. Did this kind of thing ever get added to perl?


    Jeff Kowalczyk Guest

  2. #2

    Default Re: using perl interpreter interactively like python?

    From: Jeff Kowalczyk <jtk>
    > I'd like to open perl and execute a few commands interactively in the
    > console. I learn a lot in python this way, and I need to understand
    > some perl code. Did this kind of thing ever get added to perl?
    Apart from the "debug session" explained in the previouw reply there
    is nothing "buitin", but it's all to easy to crate your own
    interactive prompt.

    See [url]http://Jenda.Krynicky.cz/#PSH[/url]

    Jenda
    ===== [email]JendaKrynicky.cz[/email] === [url]http://Jenda.Krynicky.cz[/url] =====
    When it comes to wine, women and song, wizards are allowed
    to get drunk and croon as much as they like.
    -- Terry Pratchett in Sourcery

    Jenda Krynicky Guest

  3. #3

    Default Re: using perl interpreter interactively like python?

    On Thu, 2003-11-20 at 14:25, Jeff Kowalczyk wrote:
    > I'd like to open perl and execute a few commands interactively in the
    > console. I learn a lot in python this way, and I need to understand some
    > perl code. Did this kind of thing ever get added to perl?
    I assume you're talking about how you can type $ python and enter
    whatever you want into python, and have it execute when you hit
    control-D. The same thing works in Perl, just type $ perl

    -Dan

    Dan Anderson Guest

  4. #4

    Default Re: using perl interpreter interactively like python?

    Jeff Kowalczyk wrote:
    > I'd like to open perl and execute a few commands interactively in the
    > console. I learn a lot in python this way, and I need to understand some
    > perl code. Did this kind of thing ever get added to perl?
    yes but probably not in a sense that you expect it. the perl debugger can be
    involved to work like an interactive Perl environment:

    [panda]# perl -de 1

    .... [snip a few lines] ...

    main::(-e:1): 1
    DB<1>

    at the DB<1> prompt, you can eneter anything you want. if it's not
    recognized by the debugger, it's passed directly to eval so you can do
    stuff like:

    DB<1> print "hello world\n"
    hello world

    DB<3> use strict;

    DB<4> use warnings;

    DB<5> sub sum{ \
    cont: my $sum = 0; \
    cont: $sum += $_ for(_); \
    cont: $sum; }

    DB<6> print sum(1..5),"\n";
    15

    DB<7> q
    [panda]#

    'q' will exit the debugger. lines ends with '\' signal the debugger to grab
    the next line. it's a little unusually to use the debugger for an
    interactive Perl session but it's capable of doing it.

    perldoc perldebug

    david
    --
    s,.*,<<,e,y,\n,,d,y,.s,10,,s
    ..ss.s.s...s.s....ss.....s.ss
    s.sssss.sssss...s...s..s....
    ....s.ss..s.sss..ss.s....ss.s
    s.sssss.s.ssss..ss.s....ss.s
    ...s..sss.sssss.ss.sss..ssss.
    ...sss....s.s....ss.s....ss.s

    ,....{4},"|?{*=}_'y!'+0!$&;"
    ,ge,y,!#:$_(-*[./<-{-},b-t,
    ..y...,$~=q~=?,;^_#+?{~,,$~=~
    y.!-&*-/:-^_{}.a-t ().;s,;,
    );,g,s,s,$~s,g,y,y,%,,g,eval
    David Guest

  5. #5

    Default Re: using perl interpreter interactively like python?


    On Thursday, Nov 20, 2003, at 11:25 US/Pacific, Jeff Kowalczyk wrote:
    [..]
    > I'd like to open perl and execute a few commands interactively in the
    > console. I learn a lot in python this way, and I need to understand
    > some
    > perl code. Did this kind of thing ever get added to perl?
    [..]

    first off compliments to the previous responders,
    there is the minor 'glitch' with the 'just use per'
    namely I can't quite get the AUTOFLUSH to send output,
    [jeeves: 9:] perl
    my $i=3;
    my $j = 4;
    my $k = $i + $j;
    print "k is $k\n";
    k is 7
    [jeeves: 10:]
    that print statement did not come out till I did the ^D
    even when I tried the traditional "$|=1";

    So I'd like to recommend my standard alternative,
    namely have a couple of basic templates for basic
    shell script structures and 'whip out the idea'
    and see if it flies. I use BBedit on a Mac running OSX
    so it's painfully simple for me, it has a 'run' button
    that will allow me to 'just execute it'.

    but I use to do that the old fashion way with vi on *nix boxes.
    { where one had the file in vi in one window, editing, and
    another window where one did the "!./" - to 'rerun' the previously
    locally executed command... }

    That is also what drives me to 'think' in terms of

    sub some_subname_here
    {
    my () = _;
    .....

    }

    Since I can play with an idea, if it is really
    usefulish, it is already nested in a 'sub', and
    then it is merely a matter of finding a 'home'
    for it in some appropriate Perl Module...

    Your mileage may vary, consult a physician,
    void where prohibited by law, etc, etc, etc...

    ciao
    drieux

    ---

    Drieux Guest

Similar Threads

  1. Question is there a python module for perl
    By Unregistered in forum Brainstorming Area
    Replies: 0
    Last Post: November 12th, 01:02 AM
  2. Replies: 3
    Last Post: October 22nd, 12:39 PM
  3. Full path to the perl interpreter
    By Marcos Rebelo in forum PERL Beginners
    Replies: 0
    Last Post: August 26th, 02:24 PM
  4. PHP, Perl or Python
    By MT in forum Macromedia Dreamweaver
    Replies: 2
    Last Post: July 17th, 11:04 PM
  5. Replies: 1
    Last Post: July 3rd, 10:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139