new_perl
new_perl

Reputation: 7735

What's the difference between x and p in perl -d?

  x|m expr       Evals expr in list context, dumps the result or lists methods.
  p expr         Print expression (uses script's current package).

They seems identical to me,what's different?

Also,is there any short cut like up/down arrow key in shell environment?

Upvotes: 2

Views: 223

Answers (2)

Dallaylaen
Dallaylaen

Reputation: 5318

Simply put: x prints data structures, p prints scalar values. Try both: p {x=>1, y=>2} is hardly meaningful, but x {x=>1, y=>2} makes sense.

Upvotes: 0

ysth
ysth

Reputation: 98398

See perldoc perldebug:

p expr Same as "print {$DB::OUT} expr" in the current package. In particular, because this is just Perl's own "print" function, this means that nested data structures and objects are not dumped, unlike with the "x" command.

and

Readline Support / History in the debugger As shipped, the only command-line history supplied is a simplistic one that checks for leading exclamation points. However, if you install the Term::ReadKey and Term::ReadLine modules from CPAN (such as Term::ReadLine::Gnu, Term::ReadLine::Perl, ...) you will have full editing capabilities much like GNU readline(3) provides. Look for these in the modules/by-module/Term directory on CPAN.

Upvotes: 6

Related Questions