t2.pl
1; 2; 3;
t.pl
package db; sub db { print "here"; our(undef, $f, undef) = caller; # not work # $ref = \%{ "main::_<$f" }; # $ref->{ 3 } = {}; # not work # *x = $main::{ "_<$f" }; # $x{ 3 } = {}; *dbline = $main::{ "_<$f" }; $dbline{ 3 } = {}; $db::single = 0; } 1;
perl5db="begin{ require 't.pl' }" perl -d t2.pl
when run code herehere
, magic perl variable has no effect when not alias using *dbline
.
so when change first 2 examples like:
*dbline = $main::{ "_<$f" }; # <<<<<<<<< works!!!! *x = $main::{ "_<$f" }; $x{ 3 } = { };
the breakpoint starts work. (this applied perl 5.14.4)
why work in such way?
this has been reported before:
perldebguts says:
- each hash
%{"_<$filename"}
contains breakpoints , actions keyed line number. individual entries (as opposed whole hash) settable.this implies breakpoints set on
%{"_<..."}
apply named file. not true, every%{"_<..."}
hash sets breakpoints on lines in@db::dbline
, regardless of file refers to. assumption debuggers alias*db::dbline
*{"_<..."}
before setting breakpoints.hence,
%{"_<..."}
hashes same.is case documentation should expanded match implementation? or should change implementation make each
%{"_<..."}
hash work on corresponding@{"_<..."}
array? latter seems more useful me.
in 5.20.0, behavior changed don't have alias @db::dbline
:
$ perl5db=' sub db::db { ($p,$f,$l) = caller; print "$f:$l\n"; ${"::_<$f"}{3} = 1; # no need alias $db::single = 0 } ' perl -d foo foo:1 foo:3