---
name: "Sub::HandlesVia::HandlerLibrary::Scalar"
section: "3pm"
platform: "linux"
package: "perl-sub-handlesvia"
version: "0.053005-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/Sub::HandlesVia::HandlerLibrary::Scalar"
---

# Sub::HandlesVia::HandlerLibrary::Scalar(3pm)

library of scalar-related methods

## NAME

Sub::HandlesVia::HandlerLibrary::Scalar - library of scalar-related methods

## SYNOPSIS

```
  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',
      },
    );
  }
```

## DESCRIPTION

This is a library of methods for Sub::HandlesVia.

## DELEGATABLE METHODS

### get()

Gets the current value of the scalar.

### make\_getter()

Returns a getter coderef.

```
  my $object = My::Class->new( attr => 10 );
  my $getter = $object->my_make_getter;
  $object->_set_attr( 11 );
  say $getter->(); ## ==> 11
```

### make\_setter()

Returns a setter coderef.

```
  my $object = My::Class->new( attr => 10 );
  my $setter = $object->my_make_setter;
  $setter->( 11 );
  say $object->attr; ## ==> 11
```

### scalar\_reference()

Returns a scalar reference to the attribute value's slot within its object.

```
  my $object = My::Class->new( attr => 10 );
  my $ref = $object->my_scalar_reference;
  $$ref++;
  say $object->attr; ## ==> 11
```

### set( $value )

Sets the scalar to a new value.

### stringify()

Gets the current value of the scalar, but as a string.

## BUGS

Please report any bugs to \<https://github.com/tobyink/p5-sub-handlesvia/issues\>.

## SEE ALSO

Sub::HandlesVia.

## AUTHOR

Toby Inkster \<tobyink@cpan.org\>.

## 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.
