Data::...HashDB(3pm)

πŸ“¦
version 0.14 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– 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 the record_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