Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What interative perl shell I should use to debug the perl code?

1 view
Skip to first unread message

Peng Yu

unread,
Dec 30, 2009, 10:08:15 PM12/30/09
to begi...@perl.org
It seems that there are more than one choices of perl interactive
shells. I'm wondering which one is best or most popular.

For example, I have a perl file that first load a huge data file then
do some processing on the data file. The loading time is much longer
than the processing time. If I can not run the perl file
interactively, I will have to load the data file each time I run the
processing code. However, I can interatively run perl code, I can load
the data file once and run the processing code multiple times in order
to debug the processing code.

Could somebody let me know what is the best interactive tool in perl?

Gabor Szabo

unread,
Dec 31, 2009, 2:18:33 AM12/31/09
to Peng Yu, begi...@perl.org
On Thu, Dec 31, 2009 at 5:08 AM, Peng Yu <peng...@gmail.com> wrote:
> It seems that there are more than one choices of perl interactive
> shells. I'm wondering which one is best or most popular.

I don't think there is a *best* one. There might be one that fits most
your situation and your experience level. A couple of choices:

You can start using the built in debugger by typing

perl -d script.pl

It is a very powerful command line debugger.


You can install Tk and Devel::ptkdb and then run your script via

perl -d:ptkdb script.pl

you get a debugger with a GUI.

You could buy Komodo from ActiveState, it comes with a debugger or
install Eclipse + EPIC which has a debugger or you could try
Padre, the Perl IDE which just recently - about a week ago - got its
own debugger.

While the debugger in Padre is not on par yet with the others, I'd be
especially happy if you
tried it and reported any issues or any specific feature you need so
we can include it in the
next version. http://padre.perlide.org/

Gabor

Peng Yu

unread,
Dec 31, 2009, 10:46:37 AM12/31/09
to begi...@perl.org
On Thu, Dec 31, 2009 at 1:18 AM, Gabor Szabo <sza...@gmail.com> wrote:
> On Thu, Dec 31, 2009 at 5:08 AM, Peng Yu <peng...@gmail.com> wrote:
>> It seems that there are more than one choices of perl interactive
>> shells. I'm wondering which one is best or most popular.
>
> I don't think there is a *best* one. There might be one that fits most
> your situation and your experience level. A couple of choices:
>
> You can start using the built in debugger by typing
>
> perl -d script.pl


In a 'perl -d', I try the following command, but it seems that it is
not working as I expected. Can I input any arbitrary perl commands in
the 'perl -d' session as if it is running by a perl interpreter?

DB<10> my $count = 10;

DB<11> print $count+1, "\n";
1

DB<12> print $count, "\n";


DB<13> print "$count \n";

Gabor Szabo

unread,
Dec 31, 2009, 10:59:35 AM12/31/09
to Peng Yu, begi...@perl.org
On Thu, Dec 31, 2009 at 5:46 PM, Peng Yu <peng...@gmail.com> wrote:

> In a 'perl -d', I try the following command, but it seems that it is
> not working as I expected. Can I input any arbitrary perl commands in
> the 'perl -d' session as if it is running by a perl interpreter?
>
>  DB<10> my $count = 10;
>
>  DB<11> print $count+1, "\n";
> 1
>
>  DB<12> print $count, "\n";
>
>
>  DB<13> print "$count \n";
>

The debugger wraps you command in eval calls so if you declare a
variable using 'my' it will
immediately exit the scope and get destructed.

You can do the above, just don't use 'my'.
Also you can use 'p' instead of 'print',

Gabor

Peng Yu

unread,
Dec 31, 2009, 1:59:03 PM12/31/09
to Gabor Szabo, begi...@perl.org

I want run whatever perl command in an interactive environment. If I
can not use 'my', this is not what I am looking for.

Of the tools that you recommended, which one can be used to run any
arbitrary perl command?

Peter Scott

unread,
Jan 1, 2010, 12:10:26 PM1/1/10
to begi...@perl.org
On Thu, 31 Dec 2009 12:59:03 -0600, Peng Yu wrote:
> I want run whatever perl command in an interactive environment. If I can
> not use 'my', this is not what I am looking for.
>
> Of the tools that you recommended, which one can be used to run any
> arbitrary perl command?

You have changed your requirement for what you are trying to do. You
originally stated:

> For example, I have a perl file that first load a huge data file then
> do some processing on the data file. The loading time is much longer
> than the processing time. If I can not run the perl file
> interactively, I will have to load the data file each time I run the
> processing code. However, I can interatively run perl code, I can load
> the data file once and run the processing code multiple times in order
> to debug the processing code.

For debugging an existing program as you described there, the perl
debugger is one of the best choices, and you do not need to declare new
lexical variables from the debugger to do so.

Your latest assertion sounds like you want to do something completely
different, namely to enter and run Perl code in a read-evaluate-print
loop. In which case, see this article:

http://chainsawblues.vox.com/library/post/a-perl-read-excute-print-loop-
repl.html


--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274

Jenda Krynicky

unread,
Jan 4, 2010, 4:47:12 PM1/4/10
to begi...@perl.org
From: Peng Yu <peng...@gmail.com>

> It seems that there are more than one choices of perl interactive
> shells. I'm wondering which one is best or most popular.
>
> For example, I have a perl file that first load a huge data file then
> do some processing on the data file. The loading time is much longer
> than the processing time. If I can not run the perl file
> interactively, I will have to load the data file each time I run the
> processing code. However, I can interatively run perl code, I can load
> the data file once and run the processing code multiple times in order
> to debug the processing code.

Apart from the perl debugger (that can be entered from within the
script by this (strange looking) statement:

$DB::single=2;

there's also a PSH (Perl SHell) on CPAN and another unrelated PSH on
http://Jenda.Krynicky.cz

Jenda
===== Je...@Krynicky.cz === http://Jenda.Krynicky.cz =====
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

0 new messages