MakeMe...:Scalar(3pm)

πŸ“¦
version 1.01 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… NAME πŸ’…

hii bestie πŸ’– this is the MakeMe...:Scalar(3pm) page from the User Contributed Perl Documentation, and it's all about Class::MakeMethods::Template::Scalar β€” literally Methods for blessed scalars. That's the whole name, periodt. ✨


✨ SYNOPSIS ✨

okay so here's the vibe, code and all:

package MyObject;
use Class::MakeMethods::Template::ExternalData (
  new             => 'new',
  scalar          => 'foo',
);

package main;

my $obj = MyObject->new( foo => "Foozle" );
print $obj->foo();            # Prints Foozle
$obj->foo("Bamboozle");       # Sets $$obj
print $obj->foo();            # Prints Bamboozle

🌸 DESCRIPTION 🌸

okay so this template is obsessed with the Generic object constructor and accessors meta-method types β€” it supports them, fr. But plot twist: it uses scalar refs as the underlying implementation type, so only one accessor method can be used effectively. That's the main-character constraint, bestie. πŸ’…

πŸŽ€ Standard Methods πŸŽ€

The following methods from Generic are all supported:

  • new
  • scalar
  • string
  • string_index
  • number
  • boolean
  • bits
  • array
  • hash
  • tiedhash
  • hash_of_arrays
  • object
  • instance
  • array_of_objects
  • code
  • code_or_scalar

See Class::MakeMethods::Template::Generic for the interfaces and behaviors of these method types.

⚠️ However, note that due to special nature of this package, all accessor methods reference the same scalar value, so setting a value with one method will overwrite the value retrieved by another. Like, it's giving shared-state chaos, but that's the documented behavior. πŸ™ˆ

this page is from perl v5.36.0, dated 2022-10-13, and it's filed under MakeMe...:Scalar(3pm). bye bestie, go slay those blessed scalars πŸ’–βœ¨

πŸ“¦ where this page comes from