开发者

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

开发者 https://www.devze.com 2023-03-19 17:22 出处:网络
x|m exprEvals expr in list context, dumps the result or lists methods. p exprPrint expression (uses script\'s current package).
  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开发者_StackOverflow社区 me,what's different?

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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消