/usr/share/perl5/syntax.pm is in libsyntax-perl 0.004-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | use strict;
use warnings;
# ABSTRACT: Activate syntax extensions
package syntax;
{
$syntax::VERSION = '0.004';
}
BEGIN {
$syntax::AUTHORITY = 'cpan:PHAYLON';
}
use Carp qw( carp );
use Data::OptList 0.104 qw( mkopt );
use namespace::clean;
$Carp::Internal{ +__PACKAGE__ }++;
$Carp::Internal{ 'Devel::Declare' } ||= 1;
sub import_into {
my ($class, $into, @args) = @_;
my $import = mkopt \@args;
for my $declaration (@$import) {
my ($feature, $options) = @$declaration;
$class->_install_feature(
$feature,
$into,
$options,
[@args],
);
}
return 1;
}
sub unimport_from {
my ($class, $from, @args) = @_;
for my $feature (@args) {
$class->_uninstall_feature(
$feature,
$from,
);
}
return 1;
}
sub import {
my ($class, @args) = @_;
my $caller = caller;
return $class->import_into($caller, @args);
}
sub unimport {
my ($class, @args) = @_;
my $caller = caller;
return $class->unimport_from($caller, @args);
}
sub _parse_feature_name {
my ($class, $feature) = @_;
my $name =
join '/',
map ucfirst,
split m{/},
join '',
map ucfirst,
split qr{_}, $feature;
my $file = "Syntax/Feature/${name}.pm";
my $package = $file;
s{ \/ }{::}xg, s{ \.pm \Z }{}xgi
for $package;
return $package, $file;
}
sub _uninstall_feature {
my ($class, $feature, $target) = @_;
my ($package, $file) = $class->_parse_feature_name($feature);
require $file;
unless ($package->can('uninstall')) {
carp "Syntax extension $package does not know how to uninstall";
return;
}
return $package->uninstall(
from => $target,
identifier => $feature,
);
}
sub _install_feature {
my ($class, $feature, $target, $options, $all_params) = @_;
my ($package, $file) = $class->_parse_feature_name($feature);
require $file;
return $package->install(
into => $target,
options => $options,
identifier => $feature,
outer => $all_params,
);
}
1;
__END__
=pod
=head1 NAME
syntax - Activate syntax extensions
=head1 VERSION
version 0.004
=head1 SYNOPSIS
# either
use syntax 'foo';
# or
use syntax foo => { ... };
# or
use syntax qw( foo bar ), baz => { ... };
=head1 DESCRIPTION
This module activates community provided syntax extensions to Perl. You pass it
a feature name, and optionally a scalar with arguments, and the dispatching
system will load and install the extension in your package.
The import arguments are parsed with L<Data::OptList>. There are no
standardised options. Please consult the documentation for the specific syntax
feature to find out about possible configuration options.
The passed in feature names are simply transformed: C<function> becomes
L<Syntax::Feature::Function> and C<foo_bar> would become
C<Syntax::Feature::FooBar>.
=head1 METHODS
=head2 import
syntax->import( @spec );
This method will dispatch the syntax extension setup to the specified feature
handlers for the calling package.
=head2 import_into
syntax->import_into( $into, @spec );
Same as L</import>, but performs the setup in C<$into> instead of the calling
package.
=head2 unimport
syntax->unimport( @features );
This method will trigger uninstallations of the C<@features> from the
calling package.
=head2 unimport_from
syntax->unimport_from( $from, @features );
Same as L</unimport>, but will uninstall the C<@features> from C<$from>.
=head1 RECOMMENDED FEATURES
=over
=item * L<Syntax::Feature::Function>
Activates functions with parameter signatures.
=back
=head1 SEE ALSO
L<Syntax::Feature::Function>,
L<Devel::Declare>
=head1 BUGS
Please report any bugs or feature requests to bug-syntax@rt.cpan.org or through the web interface at:
http://rt.cpan.org/Public/Dist/Display.html?Name=syntax
=head1 AUTHOR
Robert 'phaylon' Sedlacek <rs@474.at>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Robert 'phaylon' Sedlacek.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|