Man pages sections > man3 > Catmandu::Bag::IdGenerator

Catmandu::Bag::IdGenerator - A base role for bag identifier generators

Catmandu::Bag::IdGenerator(3pm) User Contributed Perl Documentation Catmandu::Bag::IdGenerator(3pm)

NAME

Catmandu::Bag::IdGenerator - A base role for bag identifier generators

SYNOPSIS

    package MyGenerator;
    use Moo;
    with 'Catmandu::Bag::IdGenerator';
    sub generate {
       my ($self, $bag) = @_;
       return $bag->name . "-" . int(ran(999999)) . "-" . time;
    }
    package main;
    my $gen = MyGenerator->new;
    for (1..100) {
       printf "id: %s\n" m $gen->generate;
    }

SEE ALSO

Catmandu::IdGenerator::Mock , Catmandu::IdGenerator::UUID
2017-10-01 perl v5.26.0