1MakeMethods::Template::USsterrucCtoBnutirlitbiunt(e3d)PMearkleMDeotchuomdesn:t:aTteimopnlate::StructBuiltin(3)
2
3
4

NAME

6       Class::MakeMethods::Template::StructBuiltin
7

SYNOPSIS

9         use Class::MakeMethods::Template::StructBuiltin (
10           -TargetClass => 'MyStat',
11           builtin_isa => [
12             '-{new_function}'=>'stat',
13               qw/ dev ino mode nlink /
14           ]
15         );
16

DESCRIPTION

18       This class generates a wrapper around some builtin function, storing
19       the results in the object and providing a by-name interface.
20
21       Takes a (core) function name, and a arrayref of return position names
22       (we will call it pos_list).  Creates:
23
24       new Calls the core func with any given arguments, stores the result in
25           the instance.
26
27       x   For each member of pos_list, creates a method of the same name
28           which gets/sets the nth member of the returned list, where n is the
29           position of x in pos_list.
30
31       fields
32           Returns pos_list, in the given order.
33
34       dump
35           Returns a list item name, item value, in order.
36
37       Example Usage:
38
39         package Stat;
40
41         use Class::MakeMethods::Template::StructBuiltin
42           builtin_isa => [ '-{new_function}'=>'stat', qw/ dev ino mode nlink / ],
43
44         package main;
45
46         my $file = "$ENV{HOME}/.template";
47         my $s = Stat->new($file);
48         print "File $file has ", $s->nlink, " links\n";
49
50       Note that (a) the new method does not check the return value of the
51       function called (in the above example, if $file does not exist, you
52       will silently get an empty object), and (b) if you really want the
53       above example, see the core File::stat module.   But you get the idea,
54       I hope.
55
56
57
58perl v5.32.1                      2021-0M1a-k2e7Methods::Template::StructBuiltin(3)
Impressum