Reputation: 301
I am wondering if there is a way to define aliases in the Perl Debugger configuration file .perldb
for the command x
which dumps expressions.
All the following imaginable varieties of alias definitions doesn't work:
cat .perldb
$DB::alias{ 'x0' } = "x '%states'"; # Does not work
$DB::alias{ 'x1' } = 'x %config'; # Does not work
$DB::alias{ 'x2' } = '"x %config"'; # Does not work
$DB::alias{ 'x3' } = 'x "%config, $foo"'; # Does not work
$DB::alias{ 'x4' } = 'x "@L"'; # Does not work
$DB::alias{ 'x5' } = 'x %config, $foo'; # Does not work
$DB::alias{ 'x6' } = '"x %config, $foo"'; # Does not work
$DB::alias{ 'xc' } = 'x %config'; # Does not work
$DB::alias{ 'pFoo1' } = 'print("foo=$var1\n")'; # Works
$DB::alias{ 'pFoo2' } = 'print("$var2\n")'; # Works
$DB::alias{ 'p1' } = 'print "\$_ = $_"'; # Works
$DB::alias{ 'code' } = 's/^.*$/l 1+99999/'; # Works
After starting the debugger with 'perl -d script.pl' and display the aliases with =
I get:
code s/^.*$/l 1+99999/
p1 print "\$_ = $_"
pFoo1 print("foo=$var1\n")
pFoo2 print("$var2\n")
x0 x '%states'
x1 x %config
x2 "x %config"
x3 x "%config, $foo"
x4 x "@L"
x5 x %config, $foo
x6 "x %config, $foo"
xc x %config
Any ideas if the alias definitions in .perldb
expect a special syntax or does it just not work?
Upvotes: 3
Views: 112
Reputation: 85837
This is not documented, but the contents of the %alias
hash are strings that are used as the right-hand side of a $cmd =~ ...
expression. That is, to work as expected, the aliases must be s///
commands.
Try something like
$DB::alias{ 'x1' } = 's/^.*/x %config/';
Upvotes: 3