perl - tips on the perl -d, fork and etc..

this is about some tricks that you can have on debuggin soem perl program.

 

 

Fork 

the first is how to debug fork process

 

 

One of the answers on the StackOverflow is like this: How to debug perl scripts that fork

the option one is like this

 

o inhibit_exit=0

 

 

 

  DB<8> o inhibit_exit=0
        inhibit_exit = '0'

 

after you set this option, you can just try to debug 'n' and then you will hit the child process.

 

p array

 

suppose that we have the following code 

 

 

  DB<7> n
main::(ph:375):   $attrs->{Attrs} =
main::(ph:376):     ($group ?
main::(ph:377):      MSDW::Directory::Group->DEFAULT_ATTRS :
main::(ph:378):      MSDW::Directory::Person->DEFAULT_ATTRS);

 and if you type 'p MSDW::Directory::Group->DEFAULT_ATTRS ', you will see the following. 

 

 

  DB<9> p @ MSDW::Directory::Group->DEFAULT_ATTRS
Can't call method "DEFAULT_ATTRS" without a package or object reference at (eval 43)[/ms/dist/perl5/PROJ/core/5.8.8-2/.exec/ia32.linux.2.4.glibc.2.3/lib/perl5/perl5db.pl:628] line 2.
 

It means that you try to inspect the address of the array (how the perl internally manage the array, I don't know)

 

 

but you can de-address the array, though I think there is some dump routines that you can use , or you can join with some spaces in between

 

 

 

  DB<11> p @{MSDW::Directory::Group->DEFAULT_ATTRS}
DescriptionEmailAddressNameRestrictedGroupType
 

 

你可能感兴趣的:(perl)