Ricardo SIGNES > Sub-MicroSig-0.032 > Sub::MicroSig

Download:
Sub-MicroSig-0.032.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.032   Source   Latest Release: Sub-MicroSig-0.033

NAME ^

Sub::MicroSig - microsigs for microvalidation of sub arguments

VERSION ^

version 0.032

SYNOPSIS ^

  use Sub::MicroSig;

  sub pow :Sig($x $pow; $trunc) {
    my $arg = shift;
    my $value = $arg->{x} ** $arg->{pow};

    $value = int $value if $arg->{trunc};
  }
  
  ...

  pow({ pow => 2, x => 4 }); # 64
  pow([ 2, 0.5, 1 ]);        #  1 # int(sqrt(2))

DESCRIPTION ^

This module allows you to give subroutine a signature using Params::Validate::Micro.

USAGE ^

To provide a signature to a subroutine, provide the attribute :Sig(), enclosing in the parentheses a valid Params::Validate::Micro argument string.

The routine will be wrapped so that its parameters are rewritten into the result of calling micro_validate on its passed arguments. If more than one argument is passed, or if the one passed argument is not an array or hash reference, an exception is thrown by Sub::MicroSig.

The the given arguments cannot be validated according to the micro-argument string, Params::Validate throws an exception.

To attach a signature to a method, use the :MethodSig() attribute. It will check that the invocant ($_[0]) is something on which a method could be called and then pass the rest of the stack on for normal micro-validation.

AUTHOR ^

Ricardo Signes, <rjbs@cpan.org>

THANKS

Thanks, Hans Dieter Pearcey! You wrote Params::Validate::Micro, and refrained from wincing when I suggested this would be a nice use of it.

BUGS ^

Please report any bugs or feature requests to bug-sub-microsig@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SEE ALSO ^

COPYRIGHT ^

Copyright 2005-2006 Ricardo SIGNES. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: