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?
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
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";
> 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
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
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