Permalink
Browse files

* use.pm 0.01.

  • Loading branch information...
1 parent 9ff59e5 commit d815fa2434534b6d55346fe033b4c13305ce4684 @audreyt committed Jul 3, 2011
Showing with 34 additions and 10 deletions.
  1. +9 −4 README
  2. +8 −4 README.mkdn
  3. +17 −2 lib/use.pm
View
13 README
@@ -20,11 +20,16 @@ SYNOPSIS
}
DESCRIPTION
- This module imports several modules at once into its caller's package.
+ This module lets you import several modules at once.
- This is almost the same as the modules module, except that "caller" is
- properly set up so syntax-altering modules based on Devel::Declare,
- Filter::Simple or Module::Compile can work corrcetly.
+ This is almost the same as modules, except that "caller" is properly set
+ up so syntax-altering modules based on Devel::Declare, Filter::Simple or
+ Module::Compile work correctly.
+
+ If a Perl version number larger than 5.9.3 appears as the first
+ argument, then it's automatically expanded just like a regular "use
+ VERSION" statement. For example, "use use '5.12.0'" expands to "use
+ strict; use feature ':5.12'".
SEE ALSO
rig, modules
View
@@ -23,11 +23,15 @@ use - Import several modules with a single use statement
# DESCRIPTION
-This module imports several modules at once into its caller's package.
+This module lets you import several modules at once.
-This is almost the same as the [modules](http://search.cpan.org/perldoc?modules) module, except that `caller`
-is properly set up so syntax-altering modules based on [Devel::Declare](http://search.cpan.org/perldoc?Devel::Declare),
-[Filter::Simple](http://search.cpan.org/perldoc?Filter::Simple) or [Module::Compile](http://search.cpan.org/perldoc?Module::Compile) can work corrcetly.
+This is almost the same as [modules](http://search.cpan.org/perldoc?modules), except that `caller` is
+properly set up so syntax-altering modules based on [Devel::Declare](http://search.cpan.org/perldoc?Devel::Declare),
+[Filter::Simple](http://search.cpan.org/perldoc?Filter::Simple) or [Module::Compile](http://search.cpan.org/perldoc?Module::Compile) work correctly.
+
+If a Perl version number larger than `5.9.3` appears as the first argument,
+then it's automatically expanded just like a regular `use VERSION` statement.
+For example, `use use '5.12.0'` expands to `use strict; use feature ':5.12'`.
# SEE ALSO
View
@@ -26,8 +26,19 @@ sub build_import {
elsif (ref $arg eq 'HASH') {
$use[-1] = { %{$use[-1]}, %$arg };
}
- elsif (is_lax($arg) and @use) {
- $use[-1]{version} = $arg;
+ elsif (is_lax($arg)) {
+ if (@use) {
+ $use[-1]{version} = $arg;
+ next;
+ }
+
+ my $perl_version = version->parse($arg)->numify;
+ push @use, { name => $perl_version };
+ if ($perl_version >= 5.009003 and $perl_version < 6) {
+ my $sub_version = int(($perl_version - 5) * 1000);
+ push @use, { name => 'strict' };
+ push @use, { name => 'feature', args => [":5.$sub_version"] };
+ }
}
else {
push @use, { name => $arg };
@@ -73,6 +84,10 @@ This is almost the same as L<modules>, except that C<caller> is
properly set up so syntax-altering modules based on L<Devel::Declare>,
L<Filter::Simple> or L<Module::Compile> work correctly.
+If a Perl version number larger than C<5.9.3> appears as the first argument,
+then it's automatically expanded just like a regular C<use VERSION> statement.
+For example, C<use use '5.12.0'> expands to C<use strict; use feature ':5.12'>.
+
=head1 SEE ALSO
L<rig>, L<modules>

0 comments on commit d815fa2

Please sign in to comment.