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::AutoBimapobject. The only valid option key is
startproviding the first value for the enumerator; defaults to
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
undefis no scalar is associated with it.
Copyright (c) 2014 Bjoern Hoehrmann <firstname.lastname@example.org>. This module is licensed under the same terms as Perl itself.