Name : perl-Syntax-Collector
| |
Version : 0.006
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp154.1.1
| Date : 2023-01-27 18:06:20
|
Group : Development/Libraries/Perl
| Source RPM : perl-Syntax-Collector-0.006-lp154.1.1.src.rpm
|
Size : 0.04 MB
| |
Packager : https://www_suse_com/
| |
Summary : collect a bundle of modules into one
|
Description :
Perl is such a flexible language that the language itself can be extended from within. (Though much of the more interesting stuff needs XS hooks like the Devel::Declare manpage.)
One problem with this is that it often requires a lot of declarations at the top of your code, loading various syntax extensions. The the syntax manpage module on CPAN addresses this somewhat by allowing you to load a bunch of features in one line, provided each syntax feature implements the necessary API:
use syntax qw/io maybe perform/;
However this introduces problems of its own. If we look at the code above, it is non-obvious that it requires the Syntax::Feature::Io manpage, the Syntax::Feature::Maybe manpage and the Syntax::Feature::Perform manpage, which makes it difficult for automated tools such as the Module::Install manpage to automatically calculate your code\'s dependencies.
Syntax::Collector to the rescue!
package Example::ProjectX::Syntax; use 5.010; use Syntax::Collector q/ use strict 0; use warnings 0; use feature 0 \':5.10\'; use Scalar::Util 1.21 qw(blessed); /;
When you \'use Syntax::Collector\', you provide a list of modules to \"collect\" into a single package (notice the \'q/.../\'). This list of modules looks like a big string of Perl code that is going to be passed to \'eval\', but don\'t let that fool you - it is not.
Each line must conform to the following pattern:
(use|no) MODULENAME VERSION (OTHERSTUFF)? ;
(Actually hash comments, and blank lines are also allowed.) The semantics of all that is pretty much what you\'d expect, except that when MODULENAME begins with \"Syntax::Feature::\" it\'s treated with some DWIMmery, and \'install\' is called instead of \'import\'. Note that VERSION is required, but if you don\'t care which version of a module you use, it\'s fine to set VERSION to 0. (Yes, VERSION is even required for pragmata.)
Now, you ask... why stuff all that structured data into a string, and parse it out again? Because to naive lexical analysis (e.g. the Module::Install manpage) it really looks like a bunch of \"use\" lines, and not just a single quoted string. This helps tools calculate the dependencies of your collection; and thus the dependencies of other code that uses your collection.
As well as providing an \'import\' method for your collection, Syntax::Collector also provides a \'modules\' method, which can be called to find out which modules a collection includes. Called in list context, it returns a list. Called in scalar context, it returns a reference to a \'{ module => version }\' hash.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-S/15.4/noarch |