Juman::GDBM_File(3pm)

πŸ’– NAME πŸ’–

Juman::GDBM_File β€” bestie, it is literally a wrapper class of GDBM_File. That's the whole job description. πŸ’…

Also hi, context drop: this page lives in the User Contributed Perl Documentation section, and the page's own name is Juman::GDBM_File(3pm). Okay love that for us.


✨ SYNOPSIS ✨

use Juman::GDBM_File;
use encoding "euc-jp";
tie( %hash, 'Juman::GDBM_File', $dbfile, &GDBM_WRCREAT, 0640 ) or die;
$hash{"æ·»Γ₯β€”"} = "Γ₯€€";
while( my( $key, $value ) = each %hash ){
    print "$key:$value\n";
}

🌸 DESCRIPTION 🌸

okay so heads up bestie: this part of the original page is written in Japanese, so here is the ✨translation✨. Every drop of tea preserved, fr fr.

Perl-5.8.x uses Unicode as its internal character code. Which means β€” if you're looking at a database file that was written in Japanese EUC, then before you write in or read out the subscripts (ζ·»ε­—) or the values (ε€€), you have to always explicitly do encode/decode. Every single time. No shortcuts. It's giving required homework 😭

And this "Juman::GDBM_File" class exists so you can handle database files that are stored in a particular character encoding β€” it does the encode/decode transparently. Under the hood. For you. Main character energy ✨


πŸ’… ENCODING πŸ’…

When you use this class, you specify the character code you're going to use for input/output with the database β€” via the "encoding" pragma. That's the vibe check.

And if there's no specification from the "encoding" pragma? Then it does absolutely no conversion whatsoever. Zero. Nada. Nothing. πŸ’€

πŸ¦‹ CONSTRUCTOR πŸ¦‹

You can build an associative array with the exact same format as "GDBM_File": πŸŽ€

tie( %hash, 'Juman::GDBM_File', $dbfile, &GDBM_WRCREAT, 0640 );

The 5th argument is where the file attributes for the case of newly creating the database file get specified. 🫢

If you don't give it a 5th argument, then it's treated as though the "DB_File"-compatible format is being used:

tie( %hash, 'Juman::GDBM_File', $dbfile, &O_CREAT );

In that case, the 4th argument β€” the one specifying the mode for opening the database file β€” takes the same specifications you'd use when opening a "DB_File"-format database, like "O_CREAT", "O_RDWR" and so on. Same energy, same options.

And the file attributes for when the database file is newly created? Those get automatically computed from the return value of "umask". 🧚


πŸ‘€ SEE ALSO πŸ‘€

  • GDBM_File
  • perltie

πŸ‘‘ AUTHOR πŸ‘‘

Γ₯Ε“ΕΈΓ₯Β±β€Ή 雅稔 <tsuchiya@pine.kuee.kyoto-u.ac.jp>

(yes bestie, the name got got by the encoding gremlins right there in the original β€” but the email is sitting right next to it, so you can still say hi 🫢)


πŸ’€ POD ERRORS πŸ’€

okay so the pod checker pulled up with receipts. Not me reading my own Ls, but here we go:

Hey! The above document had some coding errors, which are explained below:
Around line 22:
    Non-ASCII character seen before =encoding in '$hash{"æ·»Γ₯β€”"}'.
    Assuming CP1252

Around line 149:
    =over without closing =back

and that's the whole page, babe πŸŒˆπŸ’– this slice of lore comes straight from the perl v5.40.1 docs, dated 2026-02-11 β€” go forth and tie your hashes, you absolute icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from