Sub::Ha...::Number(3)
π Sub::HandlesVia::HandlerLibrary::Number π
okay bestie, welcome to the Sub::HandlesVia::HandlerLibrary::Number page β it's the library of number-related methods and it is genuinely so useful, no cap. this is the Sub::HandlesVia handler library for numbers, and she does math so you don't have to. periodt. π
β¨ SYNOPSIS β¨
look at this gorgeous little setup, she's giving main character energy:
package My::Class {
use Moo;
use Sub::HandlesVia;
use Types::Standard 'Num';
has attr => (
is => 'rwp',
isa => Num,
handles_via => 'Number',
handles => {
'my_abs' => 'abs',
'my_add' => 'add',
'my_ceil' => 'ceil',
'my_cmp' => 'cmp',
'my_div' => 'div',
'my_eq' => 'eq',
'my_floor' => 'floor',
'my_ge' => 'ge',
'my_get' => 'get',
'my_gt' => 'gt',
'my_le' => 'le',
'my_lt' => 'lt',
'my_mod' => 'mod',
'my_mul' => 'mul',
'my_ne' => 'ne',
'my_set' => 'set',
'my_sub' => 'sub',
},
);
}
πΈ DESCRIPTION πΈ
so like, this is a library of methods for Sub::HandlesVia. that's it, that's the whole vibe. π
π¦ DELEGATABLE METHODS π¦
abs()
finds the absolute value of the current number, and she updates the attribute while she's at it. iconic behavior honestly.
my $object = My::Class->new( attr => -5 );
$object->my_abs;
say $object->attr; ## ==> 5
add( $addend )
Arguments: Num.
adds a number to the existing number, updating the attribute. girl math but make it real. π
my $object = My::Class->new( attr => 4 );
$object->my_add( 5 );
say $object->attr; ## ==> 9
ceil()
finds the ceiling of the current number, updating the attribute. it's like ceil from builtin, but in-place. lowkey obsessed.
cmp( $num )
Arguments: Num.
returns $object->attr <=> $num. spaceship operator core π
div( $divisor )
Arguments: Num.
divides the existing number by a number, updating the attribute.
my $object = My::Class->new( attr => 6 );
$object->my_div( 2 );
say $object->attr; ## ==> 3
eq( $num )
Arguments: Num.
returns $object->attr == $num.
floor()
finds the floor of the current number, updating the attribute. like floor from builtin, but in-place. she stays grounded fr fr. π
ge( $num )
Arguments: Num.
returns $object->attr >= $num.
get()
returns the current value of the number. just vibes, no changes. π
my $object = My::Class->new( attr => 4 );
say $object->my_get; ## ==> 4
gt( $num )
Arguments: Num.
returns $object->attr > $num.
le( $num )
Arguments: Num.
returns $object->attr <= $num.
lt( $num )
Arguments: Num.
returns $object->attr < $num.
mod( $divisor )
Arguments: Num.
finds the current number modulo a divisor, updating the attribute.
my $object = My::Class->new( attr => 5 );
$object->my_mod( 2 );
say $object->attr; ## ==> 1
mul( $factor )
Arguments: Num.
multiplies the existing number by a number, updating the attribute.
my $object = My::Class->new( attr => 2 );
$object->my_mul( 5 );
say $object->attr; ## ==> 10
ne( $num )
Arguments: Num.
returns $object->attr != $num.
set( $value )
Arguments: Num.
sets the number to a new value. glow up moment. β¨
my $object = My::Class->new( attr => 4 );
$object->my_set( 5 );
say $object->attr; ## ==> 5
sub( $subtrahend )
Arguments: Num.
subtracts a number from the existing number, updating the attribute.
my $object = My::Class->new( attr => 9 );
$object->my_sub( 6 );
say $object->attr; ## ==> 3
π BUGS π
found a bug? not the vibe, pls report it, bestie:
<https://github.com/tobyink/p5-sub-handlesvia/issues>
π«Ά SEE ALSO π«Ά
Sub::HandlesVia.
π 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.
and that's the whole page bestie!! this was perl v5.42.0, dated 2026-02-11 β mwah, slay, bye π
πβ¨
π¦ 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