Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I'm using a library that acts on an %ENV variable being either set or not set. So, when I call it, I use
and all is well, because the code within libcall() now sees $ENV{BLAH}'s value, while other parts of the system (outside the scope of the snippet above) aren't affected by the setting. But now I want to add a condition in my code, to perform the setting only when another condition is met, but I can't use
because the 'local' directive ends with the scope of the if-body and libcall() won't see it. I can't set the variable to undef because the library checks if the value exists(). I could obviously do
but that's lame because of the code duplication. Is there a better way to 'local'ize a variable conditionally? In reply to How to localize conditionally? by saintmike
|
|