Data::...HashDB(3pm)
π Data::Stag::HashDB β the vibe β¨
okay bestie, welcome to Data::Stag::HashDB, from the User Contributed Perl Documentation collection, and it's literally the girl who builds indexes over Stag files or objects. no cap. she's giving librarian energy but make it glam. π
πΈ NAME πΈ
Data::Stag::HashDB β build indexes over Stag files or objects π¦
β¨ SYNOPSIS β¨
okay so first up, the parsing a file into a hash situation:
# parsing a file into a hash
my $hdb = Data::Stag::HashDB->new;
$hdb->unique_key("ss_details/social_security_no");
$hdb->record_type("person");
my $obj = {};
$hdb->index_hash($obj);
Data::Stag->parse(-file=>$fn, -handler=>$hdb);
my $person = $obj->{'999-9999-9999'};
print $person->xml;
and then indexing an existing stag tree into a hash, which is the same energy but you already got the tree:
# indexing an existing stag tree into a hash
my $personset = Data::Stag->parse($fn);
my $hdb = Data::Stag::HashDB->new;
$hdb->unique_key("ss_details/social_security_no");
$hdb->record_type("person");
my $obj = {};
$hdb->index_hash($obj);
$personset->sax($hdb);
my $person = $obj->{'999-9999-9999'};
print $person->xml;
see how she ate that? ππ₯
π DESCRIPTION π
so what is she for? building indexes over Stag files or objects. periodt. that's the whole job, and she does it flawlessly. π
now here's the part where you actually have to do stuff, bestie, no skipping:
- you need to provide a
record_typeβ that's the type of element that will be indexed π - you need to provide a
unique_keyβ that's a single value used to index therecord_types π
so, fr fr, if we have data in the stag structure below, and if ss_no is unique (we're assuming it is, okay, we're trusting the vibe), then we can index all the people in the database using the code above. look at her:
publicinfo:
persondata:
person:
ss_details:
social_security_no:
name:
address:
and now the tea β β there's a subclass of this method called Data::Stag::StagDB, and what she does is make the hash persistent. iconic behaviour honestly. β¨
π«Ά PUBLIC METHODS π«Ά
heads up bestie: the original is keeping it mysterious β the Usage / Returns / Args slots for these three are all just sitting there empty. not me adding anything that isn't there π so here's exactly what you get, no more no less.
π record_type
- Usage β
- Returns β
- Args β
π unique_key
- Usage β
- Returns β
- Args β
π index_hash
- Usage β
- Returns β
- Args β
and that's the whole page, bestie. go build some indexes, you're gonna slay. π
πΈ sign-off time πΈ β this whole thing came to you courtesy of perl v5.34.0, dated 2022-06-12. she's an older queen but she still hits. mwah ππ
π
π¦ where this page comes from
- debian bookworm: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libdata-stag-perl 0.14-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms