Sub::Spec::FAQ - Frequently asked questions about Sub::Spec
version 1.0.7
No. Sub::Spec is just a specification. And your sub spec is just data structure (with some coderefs, for some clauses). There are modules that do stuffs using information from the sub spec, and you 'use' those.
Sub::Spec::URI::pm expects them to be in %SPEC package variables. Most other subroutine uses Sub::Spec::URI::pm to locate local specs.
%SPEC
Nothing. Just creating the spec won't magically change your sub, the spec is just a piece of data. You need one or more modules that do stuffs to your sub using the spec. Sub::Spec::Wrapper and Sub::Spec::Exporter should be the first one to see; they implement many of the basic clauses like 'args' for argument validation, 'timeout', etc. For the rest, browse Sub::Spec::* on CPAN to see a growing list of modules. Here's a partial list:
Run subroutine from command line (see Sub::Spec::CmdLine)
Create an API service (Sub::Spec::HTTP::Server)
Use remote modules and call remote functions transparently (Sub::Spec::Use, Sub::Spec::URI::http)
Generate documentation from spec (Sub::Spec::To::*)
For a fast rule, if your clause only describes what the sub does and does not include any wrapper code, then it probably goes into features. Otherwise, it should go into a new spec clause.
features
For example, reverse is a feature clause, because it just states that if we pass -reverse => 1 argument to a sub, it will do a reverse operation. It doesn't include any wrapper code. On the other hand, 'timeout' is a spec clause because it involves the wrapping code doing an eval() and alarm() checking.
reverse
-reverse
Steven Haryanto <stevenharyanto@gmail.com>
This software is copyright (c) 2012 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Sub::Spec, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::Spec
CPAN shell
perl -MCPAN -e shell install Sub::Spec
For more information on module installation, please visit the detailed CPAN module installation guide.