in reply to bareword and hash reference
Jep, here is something strange going on. let's send the following to the debugger:
use vars qw/%x/; $x{test} = "very "; $x{test}{this} = "strange"; print $x{test}; print $x{test}{this};
the second asignment causes %x not to be changed in any way. But if you make a 'V' after it, you'll see a new hash called 'very' as a symbol available with key 'this' and value 'strange'. So what's actually happening is kind of autovivified symbolic hash-refence assignment. I suppose the docs explain it somewhere but ...
Anyway: your coworker is affecting the symbol table and that is dangerous for the code. What happens if:
$x{test} = 'ENV'; $x{test}{important_key} = 'bad value';
Yes, it clobbers the environmental variable!
--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: bareword and hash reference
by mce (Curate) on Aug 22, 2002 at 14:24 UTC | |
by fruiture (Curate) on Aug 22, 2002 at 14:30 UTC | |
by djantzen (Priest) on Aug 22, 2002 at 14:50 UTC |