in reply to Style: buried variables or double referencing?
You might even get rid of loop_count and use (0 .. $some_variable eq 'x' ? LONG_COUNT : SHORT_COUNT) directly.use constant LONG_COUNT => 14; use constant SHORT_COUNT => 9; my $some_variable; # ... my $loop_count = $some_variable eq 'x' ? LONG_COUNT : SHORT_COUNT; for $i (0 .. $loop_count) { # do some stuff print $i; }
Now LONG_COUNT and SHORT_COUNT will be easy to find and you can document them at the use constant.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Style: buried variables or double referencing?
by tilly (Archbishop) on Aug 20, 2005 at 18:12 UTC | |
by pg (Canon) on Aug 20, 2005 at 18:59 UTC | |
by tilly (Archbishop) on Aug 21, 2005 at 05:06 UTC | |
by Anonymous Monk on Aug 22, 2005 at 09:58 UTC | |
by Smylers (Pilgrim) on Aug 22, 2005 at 10:02 UTC |