On 26 Jul 2012 14:29:51 +0900, Shmuel Fomberg wrote:
>
> You probably know that the construct:
> my <variable> = <something> if <condition>;
> is problematic.
This is usually something to avoid, but it can also be useful in
some cases, if for example <condition> is a static flag.
Say, you have a working code and you want to quickly add some
temporary debug/log or similar code. You can add these lines:
...
my $debug_prefix = "[$func @args]" if $ENV{DEBUG};
...
print "$debug_prefix $some_var\n" if $ENV{DEBUG};
...
do_something_else($debug_prefix) if $ENV{DEBUG};
...
I.e. carefully use such <variable> with the same <condition> only.
Regards,
Mikhael.
--
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl