Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Perl REPLs

by davies (Parson)
on Nov 03, 2016 at 16:18 UTC ( #1175234=perlquestion: print w/replies, xml ) Need Help??
davies has asked for the wisdom of the Perl Monks concerning the following question:

Whenever I've wanted a Perl REPL, I've used the debugger, at which my expertise is limited. I know there are several others out there, such as Devel::REPL, perlconsole and Carp::REPL. I can't find anything like the one BrowserUK refers to in Re^3: Pick a single item from a sub's return list, but I didn't think the list above was exhaustive anyway. What REPLs does the Monasteriat like & dislike and why?

Regards,

John Davies

Replies are listed 'Best First'.
Re: Perl REPLs
by BrowserUk (Pope) on Nov 03, 2016 at 17:32 UTC

    My repl is basically the same 15 line perl script I wrote nearly 15 years ago. 3 years ago it looked like this.

    Today, it looks like this:

    It has at various times had more preloaded stuff, and less; and more and less logic in the loop, but the core 10 or so lines have barely changed at all.

    It has never, and will never be published because then someone would want it to "work properly with lexical variables"; "automatically print the results of every evaluation"; and "support strict"; etc. All Of which I have no need for, nor the desire to complicate my single most used perl script ever, by adding.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
      thanks!

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

        Sorry, but my repl still isn't available anywhere. If you download a copy, it becomes your repl; not mine. I hope you understand the difference.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
        In the absence of evidence, opinion is indistinguishable from prejudice.

      Very useful. Thanks.

Re: Perl REPLs
by LanX (Archbishop) on Nov 03, 2016 at 16:51 UTC
    > Whenever I've wanted a Perl REPL, I've used the debugger,

    let's first name some problems with that statement *

    • the debugger doesn't print automatically (The P in REPL)
    • the debugger is cumbersome with multi-line statements (you need to end every line with \\ )
    • it fails to handle lexical variables across lines
    • history and navigation isn't available out of the box
    • documentation and code are arcane

    I'm personally using a patched version, because I really like the

    • extensibility with aliases
    • it's already integrated in many IDEs.
    • the possibility to run bash commands directly
    • When "debugging" (i.e. analysing foreign code), I want to have the same tools at hand

    The point that stopped me from publishing a forked version was that POD and code is so deeply interwoven, that I couldn't easily fix the command loop.

    So I delayed the project till I have a POD parser ready that creates a separate perl5db.pod.

    Even scarier is that perl5db is using code in the main:: namespace which is not really obvious for me. I think it even dates back to the Perl4 era.

    Saying this I really advocate fixing it, extending the debugger to a real REPL which comes out-of-the-box would be a great plus for the Perl universe and could even lead to a Shell replacement.

    For those interested IPL: PDF and code

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

    PS: you failed to mention other projects

    footnotes

    *) to have some criteria for "good" REPLs

    2) The command loop, that's several hundred lines of code with regexes "parsing" commands ... but each block included the POD for that command.

    How do you refactor linear code where the documentation depends on the order of the code?

    I'm a fan of literate programming, but that's a good example of how not to do it. If you keep documentation close to a subroutine, you can still move that sub, not so when interspersed linear code.

Re: Perl REPLs (older threads)
by LanX (Archbishop) on Nov 03, 2016 at 18:05 UTC
Re: Perl REPLs
by VinsWorldcom (Parson) on Nov 03, 2016 at 17:02 UTC

    I've used Devel::REPL but found too many dependencies. I tried PerlConsole and Perl::Shell but found them lacking all the features I wanted. I rolled my own "borrowing" code from the above. It's not on CPAN since it's not that good, but you can find here if you're interested:

    https://github.com/vinsworldcom/PPC/tree/master/lib/PerlApp

    It's included as part of a larger Perl project which has the .pl that provides the shell for that specific project. You could of course use that as an example to write your own.

Re: Perl REPLs
by titivillus (Scribe) on Nov 03, 2016 at 16:28 UTC
    I'm on to reply these days https://metacpan.org/pod/Reply

    .witty_sig goes here

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1175234]
Approved by ww
Front-paged by LanX
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-11-16 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (192 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!