Perl Subroutine Signatures Opinion Blog

This site is an opinion blog about Perl Subroutine Signatures. Subroutine Signatures is plan to added to Perl in the near future. I have a very strong concern in the future of Perl, so I created an independent site about sub signatures. My name is Yuki Kimoto. I'm Perl Light User. I have no media power, community power, political power, and big company power. I just feel and talk about the heart of a weak perl user without a voice.

The way that CPAN authors use subroutine signatures in natural

Perl users contains CPAN authors, not only application users who use the new version of Perl.

Generally, CPAN authors use Perl old grammar to support older versions of Perl.

Most CPAN modules support Perl 5.8+, and Some modules support Perl 5.10+ and 5.12+.

CPAN authors also want to use subroutine signatures

Perl's new feature is for the new Perl, but when it comes to subroutine signatures, CPAN Author also maybe wants to use it.

If CPAN authors can use subroutine signatures, both application code and CPAN module code can be written in one source.

I think new features should work with the new Perl, but I'm happy that only the subroutine signature feature can be backported.

Wouldn't it be nice if you could use subroutine signatures with tens of thousands of CPAN modules?

But is there such a way?

Use if the perl version is lower than subroutine signatures

Use if the perl version is lower than Perl which support subroutine signatures.

I write the code. CPAN author can use instead of core subroutine signatures.

This code use SigImport. SigImport export features to Foo.

package Foo;

use strict;
use warnings;
use utf8;
use FindBin;

use lib "$FindBin::Bin";

use SigImport;

# Subroutine signatures imported from
sub func($foo) {
  return $foo;

package main;

print Foo::func(1, 2);

SigImport. This contains some fix.

package SigImport;

  require signatures;

  no warnings 'redefine';
  sub signatures::import {
    my ($class, $caller) = @_;
    $caller ||= caller();
    $pkgs{$caller} = $class->setup_for($caller);

sub import {
  my $caller = caller;
  #if ($] >= 5.034001) {
  #  feature->import('signatures');
  #else {


This code work well. Swich signatures features by Perl version.

In this way, a more several things is needed.

the number of arguments in the subroutine signature is not checked by default

the number of arguments in the subroutine signature is not checked by default.

See also the following entry.

Risk increased by checking the number of subroutine arguments is bandled to Perl core

If is bandled to Perl core, we can write the following in Makefile.PL

    PREREQ_PM => {
      '' => 0.15,

CPAN authores can switch to core subroutine signatures.

Wouldn't it be nice if you could fix the past in a subroutine signature?