开发者

Devel::Peek Question

% perl -Ilib -MDevel::Peek -le '$a="34567"; $a=~s/...//; Dump($a)' 
SV = PV(0x8171048) at 0x8186f48   # repl开发者_如何学运维aced "12345" with "34567"
  REFCNT = 1
  FLAGS = (POK,OOK,pPOK)
  OFFSET = 3
  PV = 0x8181bdb ( "34\003" . ) "67"\0
  CUR = 2
  LEN = 9

Where do the 2 zeros in the chomped part ( "12\003" . ) between 2 and 3 come from?

Why do I get this kind of output in the chomped part ( "34\003" . )?


A bug? "\003" is chr(3) in octal form. However:

$ perl -Ilib -MDevel::Peek -le '$a="12345"; $a=~s/...//; Dump($a)'
SV = PVIV(0x869b0bc) at 0x86a5060
  REFCNT = 1
  FLAGS = (POK,OOK,pPOK)
  IV = 3  (OFFSET)
  PV = 0x869fac3 ( "123" . ) "45"\0
  CUR = 2
  LEN = 5

I can't duplicate that; what version of perl are you using?

Note that the part of the string buffer in () is reserved but not currently in use.


I am getting same result as sid_com using perl 5.12.2 on Windows. However the string length is taken from CUR field of structure anyway. I don't see why this should be a bug, there can be any bytes in rest of string buffer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜