Subject: | An option to remove part of a symbol name prior to exporting |
It would be useful if one could strip out part of a symbol name prior to applying a prefix or suffix.
The context:
I have a module which contains constants (via the constant pragma) for multiple systems. In order to prevent collisions names are prepended with their subsystem, e.g.
LIMIT_SOFT
LIMIT_HARD
LINEAR_RANGE
LINEAR_CENTER
LINEAR_MIN
LINEAR_MAX
AUTOSCALE_MIN
AUTOSCALE_MAX
and are grouped with appropriate export tags (e.g. limit, linear, autoscale).
If I could strip the leading prefix from the name when importing a system's constants into code which only uses those, it would greatly clean up use.
I imagine the API might look something like
use Constants -linear => { -strip => qr/^LINEAR_/ };
which would result in RANGE, CENTER, MIN and MAXbeing exported. The string should probably be stripped prior to processing the -prefix or -suffix options. For example thsis
use Constants -autoscale => { -strip => qr/^AUTOSCALE_/,
-prefix => 'AS_' };
results in an export of AS_MIN and AS_MAX.
Thanks,
Diab