http://www.perlmonks.org?node_id=731680

LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

We've been discussing recently how handy REPL (=read-eval-print loop) is in several other languages like LISP or Python.

With perl -de0 it's possible to have a perl-shell to realize the REL-portions. But whats missing is printing!

So is it possible to enclose each line in print do {...} ???

I tried to use the debugger directives < and { but couldn't achieve that typing 10/2 results in printing 5:

DB<22> 10/2 5 DB<23>
Did I miss any autoprint option?

Cheers Rolf

PS: I know Devel::REPL, but I wonder if it's possible in the debugger...

UPDATES: similar threads I found

Replies are listed 'Best First'.
Re: using perldebugger as REPL?
by Joost (Canon) on Dec 20, 2008 at 01:20 UTC
      Wel bedankt! 8 )

      Just installed it and it looks really nice! *

      Yes, I'm anyway using emacs - actually to an extend that I fear to be reborn with 20 fingers ; )

      But nevertheless a perl only solution could be better!

      Some emacs-blues

      Unfortunately emacs-"moduls" are not as easily combinable like perl-modules.

      For instance I just discovered ECB, but how does it combine with Cperl, Sepia and PerlySense ?

      will I be able to rund the same emacs-config on the next machine, maybe a win instead of linux or will I need another week of reconfigurations ... therefore I always end with the basic config and the basic keyconfig after moving to a new system! : (

      A reliable ELPAN is really missing!

      Cheers Rolf

      UPDATE:
      (*) wow it even gets multilines right 8)

      Sepia version 0.92. Press ",h" for help, or "^D" or ",q" to exit. main @> print "a" a=> 1 main @> 10/2 => 5 main @> 5/2 => '2.5' main @> (1,2,3) 1 2 3 main @> for (1..10) { >> print >> } 12345678910=> ''
        For instance I just discovered ECB, but how does it combine with Cperl, Sepia and PerlySense ?
        And you even missed Emacs::PDE :)

        /J

        Yes, Emacs package management is laughably bad, boiling down to: (1) contribute it to GNU Emacs, (2) prefix everything, or (3) cross your fingers.

        Also, version 0.92 is a year and a half old. The latest released version, 0.97, fixes a number of bugs and adds some potentially useful features like CPAN browsing.

Re: using perldebugger as REPL?
by Jenda (Abbot) on Dec 20, 2008 at 13:30 UTC
      Thanx, I'll have a look at it.

      But the perldebugger is the standard "perl shell" and distributed with every installation ...

      So does it make sense to build parallel structures if it could be extended this way???

      I mean compare the impact on beginners while playing around with python or ruby with the need to tell them to call perl -de0 and then type x every time or alternatively to install psh.

      Looking at the documentation, I have the impression that multilines are not automatically detected. Right?

      perl$ sub Foo { perl> print "Foo called\n";<P> ERROR: Missing right bracket at (eval 3) line 5, at end of line syntax error at (eval 3) line 5, at EOF

      But I really appreciate that it supports shell-piping syntax! 8 )

      Cheers Rolf

      UPDATE:

      I just installed it as a .deb package and it works fine, especially multilines work without problems. 8 )

      But please where is the P from REPL? How can I make it autoprint, what the actual command returns? Couldn't find it in the manpage ...

      psh% for (1..3) { > print ; > } 123psh% # Multilines work smoothly 8 ) psh% 10/3 psh% # But the result is not printed like in sepia

      ----------

      OK, think I found it

      lanx@xubuntu:~$ psh psh% option echo=1 psh% 10/5 $Psh::val[0] = "2" psh%

        That's a different PSH. I did not release mine to CPAN in time and someone else released his. And I was too lazy to rename it. As far as mine goes ... it keeps accumulating lines until it finds one ending with a semicolon. I would not want it to print the return value of everything, if I want to eval and get the value I use

        psh$ ? 10/5

        It might be good if there was a REPL installed with Perl, but I bet most people would not use it anyway.