6

I am having a Perl script which internally uses dependent Perl modules from CPAN and my own project. I am using the $0 (process script name) attribute value in my script. Strangely, this value suddently becomes NULL after some dependent API calls. I am not using eval() or system() in my process. Just a regular top-down running script. Any idea what could be the reason for the vanishing of $0 value?

4

1 回答 1

9

Tie::StdScalar找出谁改变了$0.

{
   package Tie::Scalar::Croaker;
   use Tie::Scalar qw( );
   use Carp qw( confess );
   our @ISA = qw( Tie::StdScalar );
   sub FETCH { $0 }
   sub STORE { confess('$0 changed'); }
   tie($0, Tie::Scalar::Croaker::);
}
于 2013-08-02T12:02:46.507 回答