RE: spurious deaths in script execution due to read-only Config?

2011-02-24 Thread Chris Wagner
I see what ur saying but I guess I see nothing wrong with %Config being read
only and croaking if touched.



At 05:18 PM 2/23/2011 -, Brian Raven wrote:
I do recall 'perldoc perlsub' warning about localising tied hashes 
arrays being broken, and %Config::Config is a tied hash, I believe.

Regarding your work around. Map in a void context is usually frowned
upon. Perhaps grep or possibly ...

for ('now') { require ActiveState::Path }

... should have the same effect, i.e. aliasing $_ to something
(hopefully) innocuous.




--
REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
...ne cede malis

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: spurious deaths in script execution due to read-only Config?

2011-02-24 Thread Jan Dubois
On Wed, 23 Feb 2011, Brian Raven wrote:
 On Wed, 23 Feb 2011, Christian Walde wrote:

  Solution: Make sure $_ isn't pointing at %Config when Exporter.pm
  happens. This can be done as simple as this:
 
   map { require ActiveState::Path } 1;
 
  (Though i'm sure more elegant solutions exist.)
 
[...]
 
 Regarding your work around. Map in a void context is usually frowned
 upon. Perhaps grep or possibly ...
 
 for ('now') { require ActiveState::Path }
 
 ... should have the same effect, i.e. aliasing $_ to something
 (hopefully) innocuous.

It turns out the canonical solution is to add

local *_;

at the top of the subroutine.  Read all the gory details in perlsub.pod...

The important part to remember is:

local $_;

is not safe! It does not mean that $_ is now undef and that you can
do whatever you want with it.  It may still have magic attached to
it, and (in this case) it may still be associated with a tied hash
or array element.

Cheers,
-Jan

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs