cleanscore: Warnings with new perl

Ignatios Souvatzis <[email protected]> Sun, 26 Dec 2010 11:55:29 +0100
Newsgroups gmane.network.slrn.user
Message-ID <[email protected]>
Maybe I should forward this here, too... 

This is about perl 5, version 12, subversion 2 (v5.12.2) built for
arm-netbsd-thread-multi.

Message-ID: <[email protected]>
From: Ignatios Souvatzis <[email protected]>
Newsgroups: news.software.readers
Subject: [slrn] cleanscore: Warnings with new perl
Date: Fri, 10 Dec 2010 15:23:33 +0100

I stumbled upon this after upgrading perl:

marie bin !% cleanscore.old
Prototype after '%' for main::insert_comment : %% at cleanscore.old line 30.
Prototype after '%' for main::end_of_score : %$ at cleanscore.old line 31.
Prototype after '%' for main::end_of_score : %$ at cleanscore.old line 326.
Prototype after '%' for main::insert_comment : %% at cleanscore.old line 358.

After some headaches leater, trying to understand perltut and perlsub and
the code in question, I came up with the appended patch (integrated in
pkgsrc since then, and sent to the author).

Apparently, the prototypes were added a bit hastily ... or whoever
added them, knew as much about them as I did yesterday morning.

En detail:

sub foo(%) eats all parameters and passes them as a list. Inside
the sub you get the parameters one by one with "shift", for example.

sub foo(\%\%) expects two hashes as parameters (but you'd have to
consume them that way inside the subroutine).

sub foo(%%) ... well... on a call, still all parameters are eaten
and processed into a list for the subroutine, and the 2nd %, or
the $ after the %, or whatever, used to be silently ignored for a 
couple of years, but nowadays it creates a warning. 

Regards,
	-is


$NetBSD: patch-aa,v 1.1 2010/12/09 14:59:37 is Exp $

--- cleanscore.orig	2010-12-09 12:33:33.000000000 +0000
+++ cleanscore
@@ -27,8 +27,8 @@ use Getopt::Std;
 
 sub help();
 sub reset_vars(%);
-sub insert_comment(%%);
-sub end_of_score(%$);
+sub insert_comment(%);
+sub end_of_score(%);
 sub clean_file($);
 
 # globals variables.
@@ -323,7 +323,7 @@ sub clean_file($)
 
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
-sub end_of_score(%$)
+sub end_of_score(%)
 {
   my $entry = shift;
   my $file_is_changed = shift;
@@ -355,7 +355,7 @@ sub end_of_score(%$)
 
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
-sub insert_comment(%%)
+sub insert_comment(%)
 {
   my $comment=shift;
   my $entry=shift;

-- 
seal your e-mail: http://www.gnupg.org/

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl