Sub::Ha...::Scalar(3)
β¨ NAME β¨
Sub::HandlesVia::HandlerLibrary::Scalar β bestie, it's a whole library of scalar-related methods π
(okay so quick vibe check: this is a Perl manual page, Sub::Ha...::Scalar(3), from the User Contributed Perl Documentation. yes the title got abbreviated by the man renderer, that's just how it be π)
π¦ SYNOPSIS π¦
no cap, here's the whole thing:
package My::Class {
use Moo;
use Sub::HandlesVia;
use Types::Standard 'Any';
has attr => (
is => 'rwp',
isa => Any,
handles_via => 'Scalar',
handles => {
'my_get' => 'get',
'my_make_getter' => 'make_getter',
'my_make_setter' => 'make_setter',
'my_scalar_reference' => 'scalar_reference',
'my_set' => 'set',
'my_stringify' => 'stringify',
},
);
}
like... look at that. handles_via => 'Scalar' and suddenly your attribute has a whole little friend group of methods. obsessed. π
πΈ DESCRIPTION πΈ
This is a library of methods for Sub::HandlesVia. That's it, that's the description, she's concise and she knows it. β¨
π DELEGATABLE METHODS π
okay bestie here come the actual methods, this is the main character section fr fr π«Ά
π get()
Gets the current value of the scalar. that's it. simple. iconic. π
π make_getter()
Returns a getter coderef. yes a whole coderef, a little grabby function you can pass around, she's portable π
my $object = My::Class->new( attr => 10 );
my $getter = $object->my_make_getter;
$object->_set_attr( 11 );
say $getter->(); ## ==> 11
notice how the getter sees the new value even after _set_attr? because it's reading the live slot, not a stale copy. slay. π₯
π§ make_setter()
Returns a setter coderef. same energy but it writes instead of reads π
my $object = My::Class->new( attr => 10 );
my $setter = $object->my_make_setter;
$setter->( 11 );
say $object->attr; ## ==> 11
call it, attribute changes. periodt.
π scalar_reference()
Returns a scalar reference to the attribute value's slot within its object.
ngl this one is lowkey feral in the best way, because you get a reference straight into the object's guts, so you can mutate it in place and the object just... knows. π
my $object = My::Class->new( attr => 10 );
my $ref = $object->my_scalar_reference;
$$ref++;
say $object->attr; ## ==> 11
see how $$ref++ bumped the actual attribute? main character behavior. π
β set( $value )
Sets the scalar to a new value. give it $value, it goes in. done. β¨
π stringify()
Gets the current value of the scalar, but as a string. same value, stringy lil outfit on it π
π BUGS π
Please report any bugs to <https://github.com/tobyink/p5-sub-handlesvia/issues>.
(no fr, if something's broken, tell Toby, don't just suffer in silence bestie π)
π SEE ALSO π
- Sub::HandlesVia β the parent vibe, go read it
πΈ AUTHOR πΈ
Toby Inkster <tobyink@cpan.org>. legend behavior, honestly. π
π COPYRIGHT AND LICENCE π
This software is copyright (c) 2020, 2022 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
π DISCLAIMER OF WARRANTIES π
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
translation: no promises, no guarantees, you get what you get and it's giving "use at your own risk" π«Ά
and that's the whole page, bestie!! this one came from perl v5.42.0, dated 2026-02-11, and the manual page itself is Sub::Ha...::Scalar(3) β yes the name got clipped in the header, the man renderer said "we're abbreviating" and honestly? respect. π
β¨
π¦ where this page comes from
- fedora 44: perl-Sub-HandlesVia 0.053005-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms