MakeMe...uiltin(3pm)
π NAME π
okay so this is MakeMe...uiltin(3pm) from the User Contributed Perl Documentation, and the module is Class::MakeMethods::Template::StructBuiltin β it generates a wrapper around some builtin function. yes bestie, we're wrapping a builtin and giving it a by-name interface. iconic behavior, honestly β¨
πΈ SYNOPSIS πΈ
use Class::MakeMethods::Template::StructBuiltin (
-TargetClass => 'MyStat',
builtin_isa => [
'-{new_function}'=>'stat',
qw/ dev ino mode nlink /
]
);
β¨ DESCRIPTION β¨
Takes a (core) function name, and an arrayref of return position names (we will call it pos_list). Creates:
newβ calls the core func with any given arguments, stores the result in the instance.xβ for each member of pos_list, creates a method of the same name which gets/sets the nth member of the returned list, where n is the position of x in pos_list.fieldsβ returns pos_list, in the given order.dumpβ returns a list item name, item value, in order.
π§ Example Usage π§
package Stat;
use Class::MakeMethods::Template::StructBuiltin
builtin_isa => [ '-{new_function}'=>'stat', qw/ dev ino mode nlink / ],
package main;
my $file = "$ENV{HOME}/.template";
my $s = Stat->new($file);
print "File $file has ", $s->nlink, " links\n";
bestie, two notes before you run off: π
- (a) the
newmethod does not check the return value of the function called β in the above example, if$filedoes not exist, you will silently get an empty object π - (b) if you really want the above example, see the core
File::statmodule.
but you get the idea, I hope π«Ά
k bye bestie! this page is perl v5.36.0, dated 2022-10-13, and the manual is MakeMe...uiltin(3pm) β slay and stay iconic π
β¨
π¦ where this page comes from
- ubuntu noble: libclass-makemethods-perl 1.01-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libclass-makemethods-perl 1.01-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libclass-makemethods-perl 1.01-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms