hotpelmen has asked for the wisdom of the Perl Monks concerning the following question:
Background: there's a script that generates a standard-width text report by writing report into a file line by line. For most lines in the report it uses common format, but for some lines, based on some unpredictable runtime information, it needs to dynamically define a custom format. These custom formats have unpredictable "pictures", so it is impossible to pre-define all such formats in advance. Dynamic generation of custom formats is done via eval (as described in perlform). Since some lines end up using the same exact custom format, it would be beneficial to try to reuse it instead of generating and eval-ing the same string again and again.
Question: Other than maintaining a separate hash with created format names, what's the best & cheapest method of format caching here, i.e. determining if a format with a given name is already defined and available for assignment to the filehandle? I read that formats use their own namespace but I could not find any information on how to access it. Any help with this specific question would be greatly appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: caching formats
by Anonymous Monk on Jan 22, 2015 at 20:53 UTC | |
|
Re: caching formats
by LanX (Saint) on Jan 22, 2015 at 20:04 UTC | |
by locked_user sundialsvc4 (Abbot) on Jan 23, 2015 at 13:27 UTC | |
|
Re: caching formats
by Anonymous Monk on Jan 22, 2015 at 20:46 UTC | |
|
Re: caching formats
by hotpelmen (Scribe) on Jan 26, 2015 at 15:58 UTC | |
|
Re: caching formats
by locked_user sundialsvc4 (Abbot) on Jan 22, 2015 at 19:29 UTC |