En-Motion En-Motion - 7 months ago 24
Perl Question

Perlcritic - Subroutine prototypes

I'm getting this error when I run Perlcritic:


Subroutine prototypes used at line xx, column x. See page 194 of PBP.
(Severity: 5)


The subroutine is:

sub zFormatDate() {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = shift;
return sprintf("%04d%02d%02d%02d%02d%02d",
$year + 1900, $mon+1, $mday, $hour, $min, $sec);
}


If I remove the keyword 'sub' from my function it disappears.

Is this OK, or should I be looking at a different solution?

Answer

As the message suggests, you have used subroutine prototypes. You most probably do not need them.

Currently your subroutine definition may be similar to:

sub foo()

Change it to:

sub foo

Note the removal of ( and ) and anything in between.

Comments