Data::AutoBimap - Bidirectional map for enumerated strings
use Data::AutoBimap; my $bm = Data::AutoBimap->new; say $bm->s2n("Test"); # "1" say $bm->s2n("123"); # "2" say $bm->s2n("Test"); # "1" say $bm->n2s(1); # "Test" $bm->n2s(3); # undef
This module maps scalars to automatically incrementing integer values and allows to perform reverse lookups of scalars by their associated integer value.
Creates a new Data::AutoBimap object. The only valid option key is start providing the first value for the enumerator; defaults to 1.
Data::AutoBimap
start
1
Returns the number associated with the scalar; if no number has been associated with the scalar previously, associates the next consecutive number with the scalar and returns it. The scalar will be used as key in a hash.
Returns the scalar associated with the number or undef is no scalar is associated with it.
undef
None.
Copyright (c) 2014 Bjoern Hoehrmann <bjoern@hoehrmann.de>. This module is licensed under the same terms as Perl itself.
To install Data::AutoBimap, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::AutoBimap
CPAN shell
perl -MCPAN -e shell install Data::AutoBimap
For more information on module installation, please visit the detailed CPAN module installation guide.