Skip to content

Commit

Permalink
use CPAN module for older versions of Perl
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 21, 2014
1 parent f0ff29c commit 6d534e6
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/Mojo/Base.pm
Expand Up @@ -31,8 +31,8 @@ sub import {
}

# ISA
my $caller = caller;
if ($flag) {
my $caller = caller;
no strict 'refs';
push @{"${caller}::ISA"}, $flag;
*{"${caller}::has"} = sub { attr($caller, @_) };
Expand All @@ -42,11 +42,15 @@ sub import {
$_->import for qw(strict warnings utf8);
feature->import(':5.10');

# Signatures for Perl 5.20+
# Signatures
if ($^V >= 5.020000) {
feature->import('signatures');
warnings->unimport('experimental::signatures');
}
else {
require signatures;
signatures->setup_for($caller);
}
}

sub attr {
Expand Down Expand Up @@ -147,6 +151,10 @@ All three forms save a lot of typing.
feature->import('signatures');
warnings->unimport('experimental::signatures');
}
else {
require signatures;
signatures->import;
}
use IO::Handle ();
# use Mojo::Base -base;
Expand All @@ -158,6 +166,10 @@ All three forms save a lot of typing.
feature->import('signatures');
warnings->unimport('experimental::signatures');
}
else {
require signatures;
signatures->import;
}
use IO::Handle ();
use Mojo::Base;
push @ISA, 'Mojo::Base';
Expand All @@ -172,6 +184,10 @@ All three forms save a lot of typing.
feature->import('signatures');
warnings->unimport('experimental::signatures');
}
else {
require signatures;
signatures->import;
}
use IO::Handle ();
require SomeBaseClass;
push @ISA, 'SomeBaseClass';
Expand Down

0 comments on commit 6d534e6

Please sign in to comment.