}
sub add_package_symbol {
- my ($self, $variable, $initial_value) = @_; # extra args unpacked below
+ my ($self, $variable, $initial_value, %opts) = @_;
my ($name, $sigil, $type) = ref $variable eq 'HASH'
? @{$variable}{qw[name sigil type]}
# cheap fail-fast check for PERLDBf_SUBLINE and '&'
if ($^P and $^P & 0x10 && $sigil eq '&') {
- my (undef, undef, undef, $filename, $firstlinenum, $lastlinenum) = @_;
+ my $filename = $opts{filename};
+ my $first_line_num = $opts{first_line_num};
- (undef, $filename, $firstlinenum) = caller
+ (undef, $filename, $first_line_num) = caller
if not defined $filename;
- $lastlinenum = $firstlinenum ||= 0
- if not defined $lastlinenum;
+
+ my $last_line_num = $opts{last_line_num} || ($first_line_num ||= 0);
# http://perldoc.perl.org/perldebguts.html#Debugger-Internals
- $DB::sub{$pkg . '::' . $name} = "$filename:$firstlinenum-$lastlinenum";
+ $DB::sub{$pkg . '::' . $name} = "$filename:$first_line_num-$last_line_num";
}
}
is $DB::sub{'Foo::funk'}, sprintf "%s:%d-%d", __FILE__, $line, $line,
'... got the right %DB::sub value for funk default args';
-$foo_stash->add_package_symbol('&dunk' => sub { "Foo::dunk" }, "FileName", 100, 199);
+$foo_stash->add_package_symbol(
+ '&dunk' => sub { "Foo::dunk" },
+ filename => "FileName",
+ first_line_num => 100,
+ last_line_num => 199
+);
is $DB::sub{'Foo::dunk'}, sprintf "%s:%d-%d", "FileName", 100, 199,
'... got the right %DB::sub value for dunk with specified args';