Skip Menu |

This queue is for tickets about the Exporter-Tiny CPAN distribution.

Report information
The Basics
Id: 99401
Status: resolved
Priority: 0/
Queue: Exporter-Tiny

People
Owner: Nobody in particular
Requestors: djerius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 0.043_01



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
Maybe instead of: Show quoted text
> use Constants -autoscale => { -strip => qr/^AUTOSCALE_/, > -prefix => 'AS_' };
Allow: use Constants -autoscale => { -as => sub { s/^AUTOSCALE_/AS_/ } };
On Sat Oct 11 15:13:53 2014, TOBYINK wrote: Show quoted text
> Maybe instead of: >
> > use Constants -autoscale => { -strip => qr/^AUTOSCALE_/, > > -prefix => 'AS_' };
> > Allow: > > use Constants -autoscale => { -as => sub { s/^AUTOSCALE_/AS_/ } }; >
Much cleaner.
On Tue Oct 14 10:02:33 2014, DJERIUS wrote: Show quoted text
> On Sat Oct 11 15:13:53 2014, TOBYINK wrote:
> > Maybe instead of: > >
> > > use Constants -autoscale => { -strip => qr/^AUTOSCALE_/, > > > -prefix => 'AS_' };
> > > > Allow: > > > > use Constants -autoscale => { -as => sub { s/^AUTOSCALE_/AS_/ } }; > >
> > Much cleaner.
The only twist is that currently -as isn't supported for tag imports.
-as can be a coderef in 0.043_01 and above. Released 0.044 stable version today.
On Mon Jan 30 09:29:53 2017, TOBYINK wrote: Show quoted text
> -as can be a coderef in 0.043_01 and above. > > Released 0.044 stable version today.
Thanks!