If speed is a concern, among other things, you might move the declaration of @colors out into an enclosing block:
{ my @colors=(...);
sub colorize {
...
}
}
This way, @colors will still have only be 'locally' visible to colorize, but it will only be created once, at load-time, instead of every time you call colorize();. | [reply] [d/l] [select] |
And be sure that's in a BEGIN block, not just a naked block, or else there's a chance that the initializer for @colors might not have run yet.
Wrong:
{ my @colors=(...);
sub colorize {
...
}
}
Right:
BEGIN { my @colors=(...);
sub colorize {
...
}
}
| [reply] [d/l] [select] |