The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Magic::Coerce - magical coercers for scalar values

VERSION

version 0.002

SYNOPSIS

 coerce_int(my $intval = 0);

 coerce_callback($value, sub($value) { Math::Bigint->new($value) });

FUNCTIONS

coerce_int($var, $delayed = false)

This will coerce any value assigned to $var to an integer. Unless $delayed is true it will immediately coerce the value.

coerce_float($var, $delayed = false)

This will coerce any value assigned to $var to a floating point number. Unless $delayed is true it will immediately coerce the value.

coerce_string($var, $delayed = false)

This will coerce any value assigned to $var to a string. Unless $delayed is true it will immediately coerce the value.

coerce_callback($var, &callback, $delayed = false)

This will coerce the value on assignment using the callback. Unless $delayed is true it will immediately coerce the value.

AUTHOR

Leon Timmermans <leont@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2023 by Leon Timmermans.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.