Module:...ic::Tie(3)

πŸ“¦ version 1.1.3, in alpine 3.24

πŸ’… NAME πŸ’…

Module::Generic::Tie β€” bestie, it's the Object Access Control Class ✨ (and yes, it's from the User Contributed Perl Documentation section, iykyk πŸŽ€)


🌸 SYNOPSIS 🌸

my $o = My::Object->new;
tie( $o, 'Module::Generic::Tie', readonly => 1, perms => 4 );
# Attempting to change the debug level directly
$o->{debug} = 1;
# This fails, because the object is set with read only permision
# but this below will succeed
$o->debug( 1 );

okay so look at that little demo πŸ‘€ β€” you tie the object with readonly => 1 and perms => 4, and then the direct hash access $o->{debug} = 1 just does not go through (the comment literally says "This fails, because the object is set with read only permision" β€” yes, that typo is canon, keeping it verbatim πŸ’€), but calling the method $o->debug( 1 ) totally slays through. fr fr. 🫢


πŸ¦‹ VERSION πŸ¦‹

v1.2.0 β€” that's the one, bestie ⭐


✨ DESCRIPTION ✨

So here's the vibe: you hand this module an object plus a set of parameters, and it restricts direct access to the object's values β€” meaning it makes sure those properties can only be modified from inside the class/package when that's necessary πŸ‘‘.

Where you'll actually see it: this is used in "new" in Module::Generic, using your module's global variable OBJECT_PERMS. And what goes in OBJECT_PERMS? A unix permission β€” a number from 1 to 7 that's a combinatin (again, their spelling, not mine, preserving it 😭) of:

  • 1 β€” execution
  • 2 β€” write privilege
  • 4 β€” read privilege

so like, classic unix perms energy, but for your object 🌈


πŸŽ€ METHODS πŸŽ€

No method is available.

That's it. That's the section. Literally nothing. Not me showing up to the methods section and finding it empty πŸ™ˆπŸ’…


πŸ”₯ THREAD SAFETY πŸ”₯

Okay this part matters, so lock in πŸ”’:

This module does not implement locking or synchronization for tied hashes shared across threads. No cap, none.

To avoid data races:

  • Do not share tied hash instances between threads
  • Or use external synchronization (e.g., lock()) before accessing or modifying values

And the big takeaway: this module is designed primarily for permission-based encapsulation, not concurrency control. So don't come for it expecting thread magic, bestie, it will not give you that πŸ’€


🧚 AUTHOR 🧚

Jacques Deguest <jack@deguest.jp> β€” ty for your service 🫢


Copyright (c) 2000-2024 DEGUEST Pte. Ltd.

You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself. πŸ’–


and that's the whole page, bestie! 🌸 this lil number is from perl v5.42.2, dated 2026-02-15, and honestly? iconic. go forth and tie responsibly βœ¨πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from