How can you split a specific line of a required file in a Perl debugger?

I have a Perl script, name it A.plwhere the first two lines look something like this:

 require 'B.pl';
 require 'C.pl';

Where each B.pland C.plhas its own cavalcade. I need to set a breakpoint on a specific line C.pl. In GDB, I would do something like:

b C.pl:830

However, this does not seem to work at all. Is it possible? I am close?

+5
source share
4 answers

You cannot do this in one step, but you can go to the desired file and then set a breakpoint on a specific line:

DB<1> f C.pl
1    #!perl -w
2    # This is C.pl
3    # ...

DB<2> b 830

DB<3> c
+1
source

C.pl, :

$DB:single = 1;

. Ruby 'debugger'.

. : perldoc DB

+2

"R" (). :

#/usr/bin/perl -d
use strict;
use warnings;
use WWW::Mechanize;

my $agent = WWW::Mechanize->new();

, LWP:: UserAgent new(). :

bash$ perl -d sample.pl --whatever-arguments
Loading DB routines from perl5db.pl version 1.37
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main::(use_mech.pl:7):  my $foo = WWW::Mechanize::Pluggable->new();

, :

  DB<1> use LWP::UserAgent 

@INC, , ( "f" ):

  DB<2> p $INC{"LWP/UserAgent.pm"}
/Users/joemcmahon/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/LWP/UserAgent.pm

'f':

  DB<3> f /Users/joemcmahon/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/LWP/UserAgent.pm
1   package LWP::UserAgent;
2   
3:  use strict;
4:  use vars qw(@ISA $VERSION);
5   
6:  require LWP::MemberMixin;
7:  @ISA = qw(LWP::MemberMixin);
8:  $VERSION = "6.04";
9   
10: use HTTP::Request ();

new(), :

  DB<4> /new
20: sub new

sub 'l':

  DB<5> l
20  sub new
21  {
22      # Check for common user mistake
23:     Carp::croak("Options to LWP::UserAgent should be key/value pairs, not hash reference") 
24          if ref($_[1]) eq 'HASH'; 
25  
26:     my($class, %cnf) = @_;
27  
28:     my $agent = delete $cnf{agent};
29:     my $from  = delete $cnf{from};

:

  DB<5> b 23

:

  DB<6> R
Warning: some settings and command-line options may be lost!

Loading DB routines from perl5db.pl version 1.37
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main::(use_mech.pl:7):  my $foo = WWW::Mechanize::Pluggable->new();

, .

  DB<6> c
LWP::UserAgent::new(/Users/joemcmahon/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/LWP/UserAgent.pm:23):
23:     Carp::croak("Options to LWP::UserAgent should be key/value pairs, not hash reference") 
24:         if ref($_[1]) eq 'HASH'; 
  DB<6> 

import(); , . import(), . import() .

+1

c, require, .

main::(prog:6):    require "A.pl";
  DB<1> l 
6==>    require "A.pl";
7   
8:  bar();
  DB<2> c 8
main::(prog:8): bar();
  DB<3> b bar
  DB<4> c
main::bar(C.pl:2):    print "A\n";
  DB<4> 
0

All Articles