Tie
Learn about the tying process in Perl.
We'll cover the following...
Overview
Where overloading allows us to customize the behavior of classes and objects for specific types of coercion, a mechanism called tying allows us to customize the behavior of primitive variables (scalars,
arrays, hashes, and filehandles). Any operation we might perform on a tied variable translates to a specific method call on an object.
For example, the tie built-in allows the core Tie::File module to treat files as if they were arrays of records, letting us push and pop and shift as we see fit. (tie was intended to use file-backed stores for hashes and arrays, so that Perl could use data too large to fit in available memory. RAM was more expensive twenty years ago.)
...