NAME
MooseX::Types::Signal - a type to represent valid UNIX or Perl signals
VERSION
version 1.101880
SYNOPSIS
Often times you want to send a configurable signal, but you don't want someone specifying SIGLOLCAT or 1234, because those aren't valid signals. Or are they?
With this module, you don't have to know; it will figure out what is valid and what isn't, and what names map to what numbers.
Just use the Signal
type, and signal numbers are validated. Use the coercion, and you can refer to signals by name, too.
package Example;
use MooseX::Types::Signal qw(Signal);
use Moose;
has 'kill_with' => (
is => 'rw',
isa => Signal,
coerce => 1,
);
my $example = Example->new;
# kill with SIGKILL
$example->kill_with(9);
$example->kill_with('KILL');
$example->kill_with('SIGKILL');
# in any case, the reader C<kill_with> will always return 9, or
# whatever your system thinks the number for SIGKILL is
DESCRIPTION
MooseX::Types::Signal
exports a type, Signal
, that recognizes valid signals on your platform. The underlying type is a non-negative number, but there is a coercion from strings to numbers that recognizes signals by name.
There are also more restrictive types, PerlSignal
and UnixSignal
. UnixSignal
only understands signals that are in your system's signal.h
header file. PerlSignal
only understands signals that are in Perl's %Config
hash. Signal
is either/or, with preference to UnixSignal
over PerlSignal
when coercing.
EXPORTS
The exports Signal
, UnixSignal
, and PerlSignal
are exported by Sub::Exporter, so you must explicitly request them, and you can use any of Sub::Exporter's magic when doing so. This is true in general of MooseX::Types
modules.
AUTHOR
Jonathan Rockway <jrockway@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Jonathan Rockway <jrockway@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.