Doug,
This should be no problem.
If 'hello.pl', the file which includes the code to be called, looks like this,
(note the $DB::single=2):
#!/usr/bin/perl
print "Hello";
$DB::single=2;
print "World";
print "\n";
And 'wrapper.pl', the file you are calling from, looks like this:
#!/usr/bin/perl
my $filename = "hello.pl";
eval "do '$filename'";
Now you call the debugger, and your first command is 'c' (continue):
$> perl -d wrapper.pl
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(wrapper.pl:3): my $cmd = "do './hello.pl'";
DB<1> c
Hellomain::(./hello.pl:7): print "World";
DB<1> l
7==> print "World";
8
9: print "\n";
10
DB<1>
What's the problem, or have I missed something? I've just tried it with ptkdb
too, and that works fine, (stopping at the $DB::single line), also:
$> perl -d:ptkdb wrapper.pl
...
--
Richard Foley
Ciao - shorter than aufwiedersehen
http://www.rfi.net/
> Mon, 08 Jan 2007 14:07:34 -0800
> Hi all,
>
> I am running VMS perl 5.8.6. I am using persistent perl and am eval'ing a
file.
>
> The problem is, sometimes I want to eval the file to debug it. To make
matters
> worse, I need to use ptkdb to do the debugging.
>
> I've tried the obvious things like putting perl -d:ptkdb into the first line
of
> the file, and putting "use Devel::ptkdb" into PERL5LIB and PERLDBOPT all to
no
> avail.
>
> Is this even possible?
>
> Thanks in advance,
>
> -Doug
>
> Code snippet follows:
>
>
> ...{
> local *FH;
> open FH, $filename or die "open '$filename' $!";
> local($/) = undef;
> my $sub = <FH>;
> close FH;
>
> #wrap the code into a subroutine inside our unique package
> my $eval = qq{package $package; sub handler { $sub; }};
> {
> # hide our variables within this block
> my($filename,$mtime,$package,$sub);
> eval $eval;
> }
> die $@ if $@;
>
> #cache it unless we're cleaning out each time
> $Cache{$package}{mtime} = $mtime unless $delete;
> }
>
> eval {$package->handler;};
> die $@ if $@;
>