Catman...nerator(3pm)
β¨ NAME β¨
Catmandu::IdGenerator β a base role for identifier generators π
okay so picture this: you need IDs, like, a LOT of IDs, and you don't wanna hand-roll that logic every single time. so this is a role β a base role, the blueprint kind β that you with into your own class so your class becomes An Identifier Generator. it's giving template, it's giving "just give me a generate method and I'll handle the rest" π
πΈ SYNOPSIS πΈ
package MyGenerator;
use Moo;
with 'Catmandu::IdGenerator';
sub generate {
my ($self) = @_;
return int(rand(999999)) . "-" . time;
}
package main;
my $gen = MyGenerator->new;
for (1..100) {
printf "id: %s\n" m $gen->generate;
}
like. look at her go π
you roll a class, you pull in the role with with, you write your very own generate sub β and that's literally the whole job. the example does int(rand(999999)) . "-" . time which is giving chaos-chic random-number-plus-timestamp energy π₯ then in package main you build one with MyGenerator->new, loop for (1..100), and print each id.
bestie I need you to know I am copying thatprintfline character for character,mand all, exactly like the original has it. no editing, no "fixing", no notes π we reproduce, we do not rewrite. that's the rule.
π¦ SEE ALSO π¦
Catmandu::IdGenerator::Mockβ the fake one, for when you need a stand-inCatmandu::IdGenerator::UUIDβ the UUID one, for when you want the real deal β¨
and that's the whole page, bestie, short and sweet like a good iced coffee π§ this one came from the User Contributed Perl Documentation, shipped with perl v5.40.1, dated 2026-01-24. go forth and generate ids, you absolute icon πππ
π¦ where this page comes from
- ubuntu resolute: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms