On Fri, May 08, 2009 at 09:04:18PM -0400, Andrew Dunstan wrote:
>
>
> Joshua D. Drake wrote:
>> Hello,
>>
>> Here is a diff of version_stamp.pl. It is not quite done as I can't
>> actually get it to run. No matter what I do it doesn't appear to be able
>> to open configure.in.
>>
>> If someone could help me figure out where I am being stupid I would
>> appreciate it.
>
>
> Maybe you aren't running it in the right directory (i.e. the directory  
> where configure.in exists)?
>
> Anyway, I think what you want to achieve (without all the git crap) is  
> the attached.

Here's some git crap, but it makes all the .pl programs strict-clean.
Many are still horrendous, though.

Cheers,
David.
-- 
David Fetter <da...@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fet...@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
diff --git a/contrib/seg/seg-validate.pl b/contrib/seg/seg-validate.pl
index 9272936..98eb5ae 100755
--- a/contrib/seg/seg-validate.pl
+++ b/contrib/seg/seg-validate.pl
@@ -1,20 +1,24 @@
-#!/usr/bin/perl
-$integer = '[+-]?[0-9]+';
-$real    = '[+-]?[0-9]+\.[0-9]+';
-
-$RANGE   = '(\.\.)(\.)?';
-$PLUMIN  = q(\'\+\-\');
-$FLOAT   = "(($integer)|($real))([eE]($integer))?";
-$EXTENSION = '<|>|~';
-
-$boundary = "($EXTENSION)?$FLOAT";
-$deviation = $FLOAT;
-
-$rule_1 = $boundary . $PLUMIN . $deviation;
-$rule_2 = $boundary . $RANGE . $boundary;
-$rule_3 = $boundary . $RANGE;
-$rule_4 = $RANGE . $boundary;
-$rule_5 = $boundary;
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+my $integer = '[+-]?[0-9]+';
+my $real    = '[+-]?[0-9]+\.[0-9]+';
+
+my $RANGE   = '(\.\.)(\.)?';
+my $PLUMIN  = q(\'\+\-\');
+my $FLOAT   = "(($integer)|($real))([eE]($integer))?";
+my $EXTENSION = '<|>|~';
+
+my $boundary = "($EXTENSION)?$FLOAT";
+my $deviation = $FLOAT;
+
+my $rule_1 = $boundary . $PLUMIN . $deviation;
+my $rule_2 = $boundary . $RANGE . $boundary;
+my $rule_3 = $boundary . $RANGE;
+my $rule_4 = $RANGE . $boundary;
+my $rule_5 = $boundary;
 
 
 print "$rule_5\n";
diff --git a/contrib/seg/sort-segments.pl b/contrib/seg/sort-segments.pl
index 1205d3b..ade4a5d 100755
--- a/contrib/seg/sort-segments.pl
+++ b/contrib/seg/sort-segments.pl
@@ -1,7 +1,12 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
 
 # this script will sort any table with the segment data type in its last column
 
+my (@rows, @ar, $valA, $valB);
+
 while (<>) {
   chomp;
   push @rows, $_;
diff --git a/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl 
b/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl
index 6ab3763..64a0afc 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/env perl
 #
 # Copyright (c) 2001-2009, PostgreSQL Global Development Group
 #
@@ -31,22 +31,23 @@ require "ucs2utf.pl";
 #
 # first, generate UTF8 --> BIG5 table
 #
-$in_file = "BIG5.TXT";
+my $in_file = "BIG5.TXT";
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
-reset 'array';
+my %array = ();
+my $count = 0;
 
 while( <FILE> ){
        chop;
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $utf } ne "" ){
                        printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                        next;
@@ -66,15 +67,15 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
 
        # Pick only the ETEN extended characters in the range 0xf9d6 - 0xf9dc
        # from CP950.TXT
        if( $code >= 0x80 && $ucs >= 0x0080 &&
            $code >= 0xf9d6 && $code <= 0xf9dc ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $utf } ne "" ){
                        printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                        next;
@@ -85,12 +86,12 @@ while( <FILE> ){
 }
 close( FILE );
 
-$file = lc("utf8_to_big5.map");
+my $file = lc("utf8_to_big5.map");
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_utf_to_local ULmapBIG5[ $count ] = {\n";
 
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $code = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $code = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $code;
@@ -109,18 +110,18 @@ $in_file = "BIG5.TXT";
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
-reset 'array';
+%array = ();
 
 while( <FILE> ){
        chop;
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $utf } ne "" ){
                        printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                        next;
@@ -140,15 +141,15 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
 
        # Pick only the ETEN extended characters in the range 0xf9d6 - 0xf9dc
        # from CP950.TXT
        if( $code >= 0x80 && $ucs >= 0x0080 &&
            $code >= 0xf9d6 && $code <= 0xf9dc ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $utf } ne "" ){
                        printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                        next;
@@ -162,8 +163,8 @@ close( FILE );
 $file = lc("big5_to_utf8.map");
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_local_to_utf LUmapBIG5[ $count ] = {\n";
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $utf = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $utf = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $utf;
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl 
b/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
index 7649121..218bba5 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/env perl
 #
 # Copyright (c) 2001-2009, PostgreSQL Global Development Group
 #
@@ -20,7 +20,9 @@ require "ucs2utf.pl";
 
 # first generate UTF-8 --> EUC_CN table
 
-$in_file = "GB2312.TXT";
+my $in_file = "GB2312.TXT";
+my $count = 0;
+my %array = ();
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
@@ -29,11 +31,11 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $utf } ne "" ){
                        printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                        next;
@@ -49,12 +51,12 @@ close( FILE );
 # first, generate UTF8 --> EUC_CN table
 #
 
-$file = "utf8_to_euc_cn.map";
+my $file = "utf8_to_euc_cn.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_utf_to_local ULmapEUC_CN[ $count ] = {\n";
 
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $code = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $code = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $code;
@@ -69,7 +71,7 @@ close(FILE);
 #
 # then generate EUC_JP --> UTF8 table
 #
-reset 'array';
+%array = ();
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
@@ -78,11 +80,11 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $code } ne "" ){
                        printf STDERR "Warning: duplicate code: %04x\n",$ucs;
                        next;
@@ -98,8 +100,8 @@ close( FILE );
 $file = "euc_cn_to_utf8.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_local_to_utf LUmapEUC_CN[ $count ] = {\n";
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $utf = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $utf = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $utf;
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl 
b/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl
index cb95ab5..eb1b771 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/env perl
 #
 # Copyright (c) 2007-2009, PostgreSQL Global Development Group
 #
@@ -9,31 +9,30 @@
 
 require "ucs2utf.pl";
 
-$TEST = 1;
+my $TEST = 1;
 
 # first generate UTF-8 --> EUC_JIS_2004 table
 
-$in_file = "euc-jis-2004-std.txt";
+my $in_file = "euc-jis-2004-std.txt";
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
-reset 'array';
-reset 'array1';
-reset 'comment';
-reset 'comment1';
+my (%array, %array1, %comment, %comment1, $count1);
+my $count=0;
 
-while($line = <FILE> ){
+while(my $line = <FILE> ){
+    my ($c, $u, $rest, %array);
        if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) {
                $c = $1;
-               $u1 = $2;
-               $u2 = $3;
+               my $u1 = $2;
+               my $u2 = $3;
                $rest = "U+" . $u1 . "+" . $u2 . $4;
-               $code = hex($c);
-               $ucs = hex($u1);
-               $utf1 = &ucs2utf($ucs);
-               $ucs = hex($u2);
-               $utf2 = &ucs2utf($ucs);
-               $str = sprintf "%08x%08x", $utf1, $utf2;
+               my $code = hex($c);
+               my $ucs = hex($u1);
+               my $utf1 = &ucs2utf($ucs);
+               my $ucs = hex($u2);
+               my $utf2 = &ucs2utf($ucs);
+               my $str = sprintf "%08x%08x", $utf1, $utf2;
                $array1{ $str } = $code;
                $comment1{ $str } = $rest;
                $count1++;
@@ -46,9 +45,9 @@ while($line = <FILE> ){
                next;
        }
        
-       $ucs = hex($u);
-       $code = hex($c);
-       $utf = &ucs2utf($ucs);
+       my $ucs = hex($u);
+       my $code = hex($c);
+       my $utf = &ucs2utf($ucs);
        if( $array{ $utf } ne "" ){
                printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                next;
@@ -60,15 +59,15 @@ while($line = <FILE> ){
 }
 close( FILE );
 
-$file = "utf8_to_euc_jis_2004.map";
+my $file = "utf8_to_euc_jis_2004.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "/*\n";
 print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
 print FILE " */\n";
 print FILE "static pg_utf_to_local ULmapEUC_JIS_2004[] = {\n";
 
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $code = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $code = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%08x, 0x%06x} /* %s */\n", $index, $code, 
$comment{ $code };
@@ -81,22 +80,22 @@ print FILE "};\n";
 close(FILE);
 
 if ($TEST == 1) {
-       $file1 = "utf8.data";
-       $file2 = "euc_jis_2004.data";
+       my $file1 = "utf8.data";
+       my $file2 = "euc_jis_2004.data";
        open( FILE1, "> $file1" ) || die( "cannot open $file1" );
        open( FILE2, "> $file2" ) || die( "cannot open $file2" );
 
-       for $index ( sort {$a <=> $b} keys( %array ) ){
-               $code = $array{ $index };
+       for my $index ( sort {$a <=> $b} keys( %array ) ){
+               my $code = $array{ $index };
                if ($code > 0x00 && $code != 0x09 && $code != 0x0a && $code != 
0x0d &&
                        $code != 0x5c &&
                        ($code < 0x80 ||
                         ($code >= 0x8ea1 && $code <= 0x8efe) ||
                         ($code >= 0x8fa1a1 && $code <= 0x8ffefe) ||
                         ($code >= 0xa1a1 && $code <= 0x8fefe))) {
-                       for ($i = 3; $i >= 0; $i--) {
-                               $s = $i * 8;
-                               $mask = 0xff << $s;
+                       for my $i (reverse 0 .. 3) {
+                               my $s = $i * 8;
+                               my $mask = 0xff << $s;
                                print FILE1 pack("C", ($index & $mask) >> $s) 
if $index & $mask;
                                print FILE2 pack("C", ($code & $mask) >> $s) if 
$code & $mask;
                        }
@@ -113,8 +112,8 @@ print FILE " * This file was generated by 
UCS_to_EUC_JIS_2004.pl\n";
 print FILE " */\n";
 print FILE "static pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[] = 
{\n";
 
-for $index ( sort {$a cmp $b} keys( %array1 ) ){
-       $code = $array1{ $index };
+for my $index ( sort {$a cmp $b} keys( %array1 ) ){
+       my $code = $array1{ $index };
        $count1--;
        if( $count1 == 0 ){
                printf FILE "  {0x%s, 0x%s, 0x%06x}     /* %s */\n", 
substr($index, 0, 8), substr($index, 8, 8), $code, $comment1{ $index };
@@ -127,8 +126,9 @@ print FILE "};\n";
 close(FILE);
 
 if ($TEST == 1) {
-       for $index ( sort {$a cmp $b} keys( %array1 ) ){
-               $code = $array1{ $index };
+    my ($i, $s, $mask);
+       for my $index ( sort {$a cmp $b} keys( %array1 ) ){
+               my $code = $array1{ $index };
                if ($code > 0x00 && $code != 0x09 && $code != 0x0a && $code != 
0x0d &&
                        $code != 0x5c &&
                        ($code < 0x80 ||
@@ -136,16 +136,16 @@ if ($TEST == 1) {
                         ($code >= 0x8fa1a1 && $code <= 0x8ffefe) ||
                         ($code >= 0xa1a1 && $code <= 0x8fefe))) {
                        
-                       $v1 = hex(substr($index, 0, 8));
-                       $v2 = hex(substr($index, 8, 8));
+                       my $v1 = hex(substr($index, 0, 8));
+                       my $v2 = hex(substr($index, 8, 8));
 
-                       for ($i = 3; $i >= 0; $i--) {
+                       for $i (reverse 0 .. 3) {
                                $s = $i * 8;
                                $mask = 0xff << $s;
                                print FILE1 pack("C", ($v1 & $mask) >> $s) if 
$v1 & $mask;
                                print FILE2 pack("C", ($code & $mask) >> $s) if 
$code & $mask;
                        }
-                       for ($i = 3; $i >= 0; $i--) {
+                       for $i (reverse 0 .. 3) {
                                $s = $i * 8;
                                $mask = 0xff << $s;
                                print FILE1 pack("C", ($v2 & $mask) >> $s) if 
$v2 & $mask;
@@ -164,12 +164,13 @@ $in_file = "euc-jis-2004-std.txt";
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
-reset 'array';
-reset 'array1';
-reset 'comment';
-reset 'comment1';
+%array = ();
+%array1 = ();
+%comment = ();
+%comment1 = ();
 
-while($line = <FILE> ){
+while(my $line = <FILE> ){
+    my ($c, $u, $u1, $u2, $rest, $code, $ucs, $utf, $utf1, $utf2, $str);
        if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) {
                $c = $1;
                $u1 = $2;
@@ -214,8 +215,8 @@ print FILE " * This file was generated by 
UCS_to_EUC_JIS_2004.pl\n";
 print FILE " */\n";
 print FILE "static pg_local_to_utf LUmapEUC_JIS_2004[] = {\n";
 
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $code = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $code = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%06x, 0x%08x} /* %s */\n", $index, $code, 
$comment{ $code };
@@ -234,8 +235,8 @@ print FILE " * This file was generated by 
UCS_to_EUC_JIS_2004.pl\n";
 print FILE " */\n";
 print FILE "static pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[] = 
{\n";
 
-for $index ( sort {$a <=> $b} keys( %array1 ) ){
-       $code = $array1{ $index };
+for my $index ( sort {$a <=> $b} keys( %array1 ) ){
+       my $code = $array1{ $index };
        $count1--;
        if( $count1 == 0 ){
                printf FILE "  {0x%06x, 0x%s, 0x%s}     /* %s */\n", $index, 
substr($code, 0, 8), substr($code, 8, 8), $comment1{ $index };
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl 
b/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl
index 81b0a37..92d3d4d 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/env perl
 #
 # Copyright (c) 2001-2009, PostgreSQL Global Development Group
 #
@@ -34,22 +34,23 @@ require "ucs2utf.pl";
 #
 # JIS0201
 #
-$in_file = "JIS0201.TXT";
+my $in_file = "JIS0201.TXT";
+my $count = 0;
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
-reset 'array';
+my %array = ();
 
 while( <FILE> ){
        chop;
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $utf } ne "" ){
                        printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                        next;
@@ -74,11 +75,11 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $s, $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $s, $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $utf } ne "" ){
                        printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                        next;
@@ -102,11 +103,11 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $utf } ne "" ){
                        printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                        next;
@@ -122,12 +123,12 @@ close( FILE );
 # first, generate UTF8 --> EUC_JP table
 #
 
-$file = "utf8_to_euc_jp.map";
+my $file = "utf8_to_euc_jp.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_utf_to_local ULmapEUC_JP[ $count ] = {\n";
 
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $code = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $code = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $code;
@@ -150,18 +151,18 @@ $in_file = "JIS0201.TXT";
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
-reset 'array';
+%array = ();
 
 while( <FILE> ){
        chop;
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $code } ne "" ){
                        printf STDERR "Warning: duplicate code: %04x\n",$ucs;
                        next;
@@ -187,11 +188,11 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $s, $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $s, $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $code } ne "" ){
                        printf STDERR "Warning: duplicate code: %04x\n",$ucs;
                        next;
@@ -216,11 +217,11 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $code } ne "" ){
                        printf STDERR "Warning: duplicate code: %04x\n",$ucs;
                        next;
@@ -236,8 +237,8 @@ close( FILE );
 $file = "euc_jp_to_utf8.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_local_to_utf LUmapEUC_JP[ $count ] = {\n";
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $utf = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $utf = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $utf;
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl 
b/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl
index 3d2745a..f26f630 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/env perl
 #
 # Copyright (c) 2001-2009, PostgreSQL Global Development Group
 #
@@ -20,7 +20,9 @@ require "ucs2utf.pl";
 
 # first generate UTF-8 --> EUC_KR table
 
-$in_file = "KSX1001.TXT";
+my $in_file = "KSX1001.TXT";
+my $count = 0;
+my %array = ();
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
@@ -29,11 +31,11 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $utf } ne "" ){
                        printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                        next;
@@ -49,12 +51,12 @@ close( FILE );
 # first, generate UTF8 --> EUC_KR table
 #
 
-$file = "utf8_to_euc_kr.map";
+my $file = "utf8_to_euc_kr.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_utf_to_local ULmapEUC_KR[ $count ] = {\n";
 
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $code = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $code = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $code;
@@ -69,7 +71,7 @@ close(FILE);
 #
 # then generate EUC_JP --> UTF8 table
 #
-reset 'array';
+%array = ();
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
@@ -78,11 +80,11 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $code } ne "" ){
                        printf STDERR "Warning: duplicate code: %04x\n",$ucs;
                        next;
@@ -98,8 +100,8 @@ close( FILE );
 $file = "euc_kr_to_utf8.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_local_to_utf LUmapEUC_KR[ $count ] = {\n";
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $utf = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $utf = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $utf;
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl 
b/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl
index e5a9bdd..fa4fb37 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/env perl
 #
 # Copyright (c) 2001-2009, PostgreSQL Global Development Group
 #
@@ -21,7 +21,9 @@ require "ucs2utf.pl";
 
 # first generate UTF-8 --> EUC_TW table
 
-$in_file = "CNS11643.TXT";
+my $in_file = "CNS11643.TXT";
+my $count = 0;
+my %array;
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
@@ -30,18 +32,18 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $utf } ne "" ){
                        printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                        next;
                }
                $count++;
 
-               $plane = ($code & 0x1f0000) >> 16;
+               my $plane = ($code & 0x1f0000) >> 16;
                if ($plane > 16) {
                        printf STDERR "Warning: invalid plane No.$plane. 
ignored\n";
                        next;
@@ -60,12 +62,12 @@ close( FILE );
 # first, generate UTF8 --> EUC_TW table
 #
 
-$file = "utf8_to_euc_tw.map";
+my $file = "utf8_to_euc_tw.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_utf_to_local ULmapEUC_TW[ $count ] = {\n";
 
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $code = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $code = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $code;
@@ -80,7 +82,7 @@ close(FILE);
 #
 # then generate EUC_JP --> UTF8 table
 #
-reset 'array';
+%array = ();
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
@@ -89,18 +91,18 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $code } ne "" ){
                        printf STDERR "Warning: duplicate code: %04x\n",$ucs;
                        next;
                }
                $count++;
 
-               $plane = ($code & 0x1f0000) >> 16;
+               my $plane = ($code & 0x1f0000) >> 16;
                if ($plane > 16) {
                        printf STDERR "Warning: invalid plane No.$plane. 
ignored\n";
                        next;
@@ -120,8 +122,8 @@ close( FILE );
 $file = "euc_tw_to_utf8.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_local_to_utf LUmapEUC_TW[ $count ] = {\n";
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $utf = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $utf = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $utf;
diff --git a/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl 
b/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
index 3695320..2baf235 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
@@ -1,4 +1,5 @@
-#! /usr/bin/perl
+#!/usr/bin/env perl
+
 #
 # Copyright 2002 by Bill Huang
 #
@@ -20,7 +21,9 @@ require "ucs2utf.pl";
 
 # first generate UTF-8 --> GB18030 table
 
-$in_file = "ISO10646-GB18030.TXT";
+my $in_file = "ISO10646-GB18030.TXT";
+my $count = 0;
+my %array;
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
@@ -29,11 +32,11 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $u, $c, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $u, $c, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $utf } ne "" ){
                        printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
                        next;
@@ -49,12 +52,12 @@ close( FILE );
 # first, generate UTF8 --> GB18030 table
 #
 
-$file = "utf8_to_gb18030.map";
+my $file = "utf8_to_gb18030.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_utf_to_local ULmapGB18030[ $count ] = {\n";
 
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $code = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $code = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $code;
@@ -69,7 +72,7 @@ close(FILE);
 #
 # then generate GB18030 --> UTF8 table
 #
-reset 'array';
+%array = ();
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
@@ -78,11 +81,11 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $u, $c, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $u, $c, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                if( $array{ $code } ne "" ){
                        printf STDERR "Warning: duplicate code: %04x\n",$ucs;
                        next;
@@ -97,8 +100,8 @@ close( FILE );
 $file = "gb18030_to_utf8.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_local_to_utf LUmapGB18030[ $count ] = {\n";
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $utf = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $utf = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $utf;
diff --git a/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl 
b/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl
index 6554dca..74552d8 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl
@@ -11,16 +11,15 @@ require "ucs2utf.pl";
 
 # first generate UTF-8 --> SHIFT_JIS_2004 table
 
-$in_file = "sjis-0213-2004-std.txt";
+my $in_file = "sjis-0213-2004-std.txt";
+my $count = 0;
+my $count1 = 0;
+my (%array, %array1, %comment, %comment1);
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
-reset 'array';
-reset 'array1';
-reset 'comment';
-reset 'comment1';
-
-while($line = <FILE> ){
+while(my $line = <FILE> ){
+    my ($c, $u, $u1, $u2, $rest, $code, $ucs, $utf, $utf1, $utf2, $str);
        if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) {
                $c = $1;
                $u1 = $2;
@@ -58,15 +57,15 @@ while($line = <FILE> ){
 }
 close( FILE );
 
-$file = "utf8_to_shift_jis_2004.map";
+my $file = "utf8_to_shift_jis_2004.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "/*\n";
 print FILE " * This file was generated by UCS_to_SHIFT_JIS_2004.pl\n";
 print FILE " */\n";
 print FILE "static pg_utf_to_local ULmapSHIFT_JIS_2004[] = {\n";
 
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $code = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $code = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%08x, 0x%06x} /* %s */\n", $index, $code, 
$comment{ $code };
@@ -85,8 +84,8 @@ print FILE " * This file was generated by 
UCS_to_SHIFT_JIS_2004.pl\n";
 print FILE " */\n";
 print FILE "static pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[] = 
{\n";
 
-for $index ( sort {$a cmp $b} keys( %array1 ) ){
-       $code = $array1{ $index };
+for my $index ( sort {$a cmp $b} keys( %array1 ) ){
+       my $code = $array1{ $index };
        $count1--;
        if( $count1 == 0 ){
                printf FILE "  {0x%s, 0x%s, 0x%04x}     /* %s */\n", 
substr($index, 0, 8), substr($index, 8, 8), $code, $comment1{ $index };
@@ -104,12 +103,13 @@ $in_file = "sjis-0213-2004-std.txt";
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
-reset 'array';
-reset 'array1';
-reset 'comment';
-reset 'comment1';
+%array = ();
+%array1 = ();
+%comment = ();
+%comment1 = ();
 
-while($line = <FILE> ){
+while(my $line = <FILE> ){
+    my ($c, $u, $u1, $u2, $rest, $code, $ucs, $utf, $utf1, $utf2, $str);
        if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) {
                $c = $1;
                $u1 = $2;
@@ -155,8 +155,8 @@ print FILE " * This file was generated by 
UCS_to_SHIFTJIS_2004.pl\n";
 print FILE " */\n";
 print FILE "static pg_local_to_utf LUmapSHIFT_JIS_2004[] = {\n";
 
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $code = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $code = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%08x} /* %s */\n", $index, $code, 
$comment{ $code };
@@ -175,8 +175,8 @@ print FILE " * This file was generated by 
UCS_to_SHIFT_JIS_2004.pl\n";
 print FILE " */\n";
 print FILE "static pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = 
{\n";
 
-for $index ( sort {$a <=> $b} keys( %array1 ) ){
-       $code = $array1{ $index };
+for my $index ( sort {$a <=> $b} keys( %array1 ) ){
+       my $code = $array1{ $index };
        $count1--;
        if( $count1 == 0 ){
                printf FILE "  {0x%04x, 0x%s, 0x%s}     /* %s */\n", $index, 
substr($code, 0, 8), substr($code, 8, 8), $comment1{ $index };
diff --git a/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl 
b/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
index c04d47c..ce1d629 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/perl
 #
 # Copyright (c) 2001-2009, PostgreSQL Global Development Group
 #
@@ -21,8 +21,9 @@ require "ucs2utf.pl";
 
 # first generate UTF-8 --> SJIS table
 
-$in_file = "CP932.TXT";
-$count = 0;
+my $in_file = "CP932.TXT";
+my $count = 0;
+my %array;
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
@@ -31,11 +32,11 @@ while( <FILE> ){
   if( /^#/ ){
       next;
    }
-    ( $c, $u, $rest ) = split;
-  $ucs = hex($u);
-  $code = hex($c);
+  my ( $c, $u, $rest ) = split;
+  my $ucs = hex($u);
+  my $code = hex($c);
   if( $code >= 0x80 && $ucs >= 0x0080 ){
-    $utf = &ucs2utf($ucs);
+    my $utf = &ucs2utf($ucs);
     if((( $code >= 0xed40 )
        && ( $code <= 0xeefc ))
        || (( $code >= 0x8754 )
@@ -66,12 +67,12 @@ close( FILE );
 # first, generate UTF8 --> SJIS table
 #
 
-$file = "utf8_to_sjis.map";
+my $file = "utf8_to_sjis.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_utf_to_local ULmapSJIS[ $count ] = {\n";
 
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $code = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $code = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $code;
@@ -89,7 +90,7 @@ close(FILE);
 
 open( FILE, $in_file ) || die( "cannot open $in_file" );
 
-reset 'array';
+%array = ();
 $count = 0;
 
 while( <FILE> ){
@@ -97,11 +98,11 @@ while( <FILE> ){
        if( /^#/ ){
                next;
        }
-       ( $c, $u, $rest ) = split;
-       $ucs = hex($u);
-       $code = hex($c);
+       my ( $c, $u, $rest ) = split;
+       my $ucs = hex($u);
+       my $code = hex($c);
        if( $code >= 0x80 && $ucs >= 0x0080 ){
-               $utf = &ucs2utf($ucs);
+               my $utf = &ucs2utf($ucs);
                $count++;
 
                $array{ $code } = $utf;
@@ -112,8 +113,8 @@ close( FILE );
 $file = "sjis_to_utf8.map";
 open( FILE, "> $file" ) || die( "cannot open $file" );
 print FILE "static pg_local_to_utf LUmapSJIS[ $count ] = {\n";
-for $index ( sort {$a <=> $b} keys( %array ) ){
-       $utf = $array{ $index };
+for my $index ( sort {$a <=> $b} keys( %array ) ){
+       my $utf = $array{ $index };
        $count--;
        if( $count == 0 ){
                printf FILE "  {0x%04x, 0x%04x}\n", $index, $utf;
diff --git a/src/backend/utils/mb/Unicode/UCS_to_most.pl 
b/src/backend/utils/mb/Unicode/UCS_to_most.pl
old mode 100644
new mode 100755
index 8fd5c86..3febf18
--- a/src/backend/utils/mb/Unicode/UCS_to_most.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_most.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/env perl
 #
 # Copyright (c) 2001-2009, PostgreSQL Global Development Group
 #
@@ -17,7 +17,7 @@
 
 require "ucs2utf.pl";
 
-%filename = (
+my %filename = (
        'WIN866' => 'CP866.TXT',
        'WIN874' => 'CP874.TXT',
        'WIN1250' => 'CP1250.TXT',
@@ -49,29 +49,30 @@ require "ucs2utf.pl";
        'JOHAB' => 'JOHAB.TXT',
 );
 
-...@charsets = keys(filename);
+my @charsets = keys(%filename);
 @charsets = @ARGV if scalar(@ARGV);
-foreach $charset (@charsets) {
+foreach my $charset (@charsets) {
 
 #
 # first, generate UTF8-> charset table
 #
-    $in_file = $filename{$charset};
+    my $in_file = $filename{$charset};
 
     open( FILE, $in_file ) || die( "cannot open $in_file" );
 
-       reset 'array';
+       my %array;
+    my $count = 0;
 
     while( <FILE> ){
                chop;
                if( /^#/ ){
                        next;
                }
-               ( $c, $u, $rest ) = split;
-               $ucs = hex($u);
-               $code = hex($c);
+               my ( $c, $u, $rest ) = split;
+               my $ucs = hex($u);
+               my $code = hex($c);
                if( $code >= 0x80 && $ucs >= 0x0080){
-                       $utf = &ucs2utf($ucs);
+                       my $utf = &ucs2utf($ucs);
                        if( $array{ $utf } ne "" ){
                                printf STDERR "Warning: duplicate UTF8: 
%04x\n",$ucs;
                                next;
@@ -82,12 +83,12 @@ foreach $charset (@charsets) {
        }
     close( FILE );
 
-       $file = lc("utf8_to_${charset}.map");
+       my $file = lc("utf8_to_${charset}.map");
     open( FILE, "> $file" ) || die( "cannot open $file" );
        print FILE "static pg_utf_to_local ULmap${charset}[ $count ] = {\n";
 
-       for $index ( sort {$a <=> $b} keys( %array ) ){
-               $code = $array{ $index };
+       for my $index ( sort {$a <=> $b} keys( %array ) ){
+               my $code = $array{ $index };
                $count--;
                if( $count == 0 ){
                        printf FILE "  {0x%04x, 0x%04x}\n", $index, $code;
@@ -104,18 +105,18 @@ foreach $charset (@charsets) {
 #
     open( FILE, $in_file ) || die( "cannot open $in_file" );
 
-       reset 'array';
+       %array = ();
 
     while( <FILE> ){
                chop;
                if( /^#/ ){
                        next;
                }
-               ( $c, $u, $rest ) = split;
-               $ucs = hex($u);
-               $code = hex($c);
+               my ( $c, $u, $rest ) = split;
+               my $ucs = hex($u);
+               my $code = hex($c);
                if($code >= 0x80 && $ucs >= 0x0080){
-                       $utf = &ucs2utf($ucs);
+                       my $utf = &ucs2utf($ucs);
                        if( $array{ $code } ne "" ){
                                printf STDERR "Warning: duplicate UTF8: 
%04x\n",$ucs;
                                next;
@@ -129,8 +130,8 @@ foreach $charset (@charsets) {
        $file = lc("${charset}_to_utf8.map");
     open( FILE, "> $file" ) || die( "cannot open $file" );
        print FILE "static pg_local_to_utf LUmap${charset}[ $count ] = {\n";
-       for $index ( sort {$a <=> $b} keys( %array ) ){
-               $utf = $array{ $index };
+       for my $index ( sort {$a <=> $b} keys( %array ) ){
+               my $utf = $array{ $index };
                $count--;
                if( $count == 0 ){
                        printf FILE "  {0x%04x, 0x%04x}\n", $index, $utf;
diff --git a/src/backend/utils/mb/Unicode/ucs2utf.pl 
b/src/backend/utils/mb/Unicode/ucs2utf.pl
old mode 100644
new mode 100755
index a187015..cd6279a
--- a/src/backend/utils/mb/Unicode/ucs2utf.pl
+++ b/src/backend/utils/mb/Unicode/ucs2utf.pl
@@ -4,9 +4,12 @@
 # $PostgreSQL$
 # convert UCS-4 to UTF-8
 #
+use strict;
+use warnings;
+
 sub ucs2utf {
-       local($ucs) = @_;
-       local $utf;
+       my($ucs) = @_;
+       my $utf;
 
        if ($ucs <= 0x007f) {
                $utf = $ucs;
diff --git a/src/interfaces/ecpg/preproc/parse.pl 
b/src/interfaces/ecpg/preproc/parse.pl
old mode 100644
new mode 100755
index 2907171..6c724bc
--- a/src/interfaces/ecpg/preproc/parse.pl
+++ b/src/interfaces/ecpg/preproc/parse.pl
@@ -1,4 +1,8 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
 # $PostgreSQL$
 # parser generater for ecpg
 # call with backend parser as stdin
@@ -11,6 +15,8 @@
 # Placed under the same license as PostgreSQL.
 #
 
+my ($path, @Fld, %opened, %buffcnt, $non_term_id);
+
 if (@ARGV) {
        $path = $ARGV[0];
        shift @ARGV;
@@ -18,25 +24,27 @@ if (@ARGV) {
 
 if ($path eq '') { $path = "."; }
 
-$[ = 1;                        # set array base to 1
-$, = ' ';              # set output field separator
-$\ = "\n";             # set output record separator
+local $[ = 1;                  # set array base to 1
+local $, = ' ';                # set output field separator
+local $\ = "\n";               # set output record separator
 
-$copymode = 'off';
-$brace_indent = 0;
-$yaccmode = 0;
-$header_included = 0;
-$feature_not_supported = 0;
-$tokenmode = 0;
+my $copymode = 'off';
+my $brace_indent = 0;
+my $yaccmode = 0;
+my $header_included = 0;
+my $feature_not_supported = 0;
+my $tokenmode = 0;
 
 # some token have to be replaced by other symbols
 # either in the rule
+my %replace_token;
 $replace_token{'BCONST'} = 'ecpg_bconst';
 $replace_token{'FCONST'} = 'ecpg_fconst';
 $replace_token{'Sconst'} = 'ecpg_sconst';
 $replace_token{'IDENT'} = 'ecpg_ident';
 $replace_token{'PARAM'} = 'ecpg_param';
 # or in the block
+my %replace_string;
 $replace_string{'WITH_TIME'} = 'with time';
 $replace_string{'NULLS_FIRST'} = 'nulls first';
 $replace_string{'NULLS_LAST'} = 'nulls last';
@@ -44,6 +52,7 @@ $replace_string{'TYPECAST'} = '::';
 
 # specific replace_types for specific non-terminals - never include the ':'
 # ECPG-only replace_types are defined in ecpg-replace_types
+my %replace_types;
 $replace_types{'PrepareStmt'} = '<prep>';
 $replace_types{'opt_array_bounds'} = '<index>';
 # "ignore" means: do not create type and rules for this non-term-id
@@ -57,6 +66,7 @@ $replace_types{'unreserved_keyword'} = 'ignore';
 $replace_types{'Sconst'} = 'ignore';
 
 # some production rules have to be ignored or replaced
+my %replace_line;
 $replace_line{'fetch_direction'} = 'ignore';
 $replace_line{"opt_array_boundsopt_array_bounds'['Iconst']'"} = 'ignore';
 $replace_line{'col_name_keywordCHAR_P'} = 'ignore';
@@ -74,6 +84,11 @@ 
$replace_line{'PrepareStmtPREPAREnameprep_type_clauseASPreparableStmt'} = 'PREPA
 $replace_line{'var_nameColId'} = 'ECPGColId';
 
 line: while (<>) {
+    my ($infield, $fieldcount, $S, $s, $n, @arr, $str, $type,
+        $comment, $fieldIndexer, $includetype, $fields, $field_count,
+        $line, $tstr, $prec, $nfield, $stmt_mode,
+        %fields, %tokens);
+
     chomp;     # strip record separator
     @Fld = split(' ', $_, -1);
 
@@ -308,10 +323,11 @@ print 'prog: statements;';
 &dump('trailer');
 
 sub include_stuff {
-    local($includestream, $includefilename, $includeblock, $copy, 
$field_count) = @_;
-    $copied = 0;
-    $inblock = 0;
-    $filename = $path . "/" . $includefilename;
+    my($includestream, $includefilename, $includeblock, $copy, $field_count) = 
@_;
+    my $copied = 0;
+    my $inblock = 0;
+    my ($includetype, $getline_ok, $stmt_mode, $line);
+    my $filename = $path . "/" . $includefilename;
     while (($_ = &Getline2($filename),$getline_ok)) {
        if ($includeblock ne '' && $Fld[1] eq 'ECPG:' && $inblock == 0) {
            if ($Fld[2] eq $includeblock) {
@@ -349,12 +365,14 @@ sub include_stuff {
 }
 
 sub add_to_buffer {
-    local($buffer, $str) = @_;
+    my($buffer, $str) = @_;
+    my %buff;
     $buff{$buffer, $buffcnt{$buffer}++} = $str;
 }
 
 sub dump {
-    local($buffer) = @_;
+    my($buffer) = @_;
+    my %buff;
     print '/* ' . $buffer . ' */';
     for ($a = 0; $a < $buffcnt{$buffer}; $a++) {
        print $buff{$buffer, $a};
@@ -362,7 +380,8 @@ sub dump {
 }
 
 sub dump_fields {
-    local($mode, *flds, $len, $ln) = @_;
+    my (%flds, $mode, $len, $ln, $cnt, $z, %flds_new, $str, $literal_mode);
+    ($mode, *flds, $len, $ln) = @_;
     if ($mode == 0) {
        #Normal 
        &add_to_buffer('rules', $ln);
@@ -389,7 +408,7 @@ sub dump_fields {
                    next;
                }
 
-               $str = $flds{$z};
+               my $str = $flds{$z};
 
                while (1) {
                    if ($z >= $len - 1 || substr($flds{$z + 1}, 1, 1) eq "\$") {
@@ -437,7 +456,8 @@ sub dump_fields {
 }
 
 sub generate_block {
-    local($line) = @_;
+    my($line) = @_;
+    my ($block, $s);
     $block = $non_term_id . $line;
     $s = ' ', $block =~ s/$s//g;
     $s = "\\|", $block =~ s/$s//g;
@@ -445,7 +465,8 @@ sub generate_block {
 }
 
 sub dump_line {
-    local($stmt_mode, $fields, $field_count) = @_;
+    my($stmt_mode, $fields, $field_count) = @_;
+    my ($block, $line);
     $block = &generate_block($line);
     if ($replace_line{$block} eq 'ignore') {
        return 0;
@@ -460,7 +481,7 @@ sub dump_line {
        $block = &generate_block($line);
     }
     &add_to_buffer('rules', $line);
-    $i = &include_stuff('rules', 'ecpg.addons', $block, 0, $field_count);
+    my $i = &include_stuff('rules', 'ecpg.addons', $block, 0, $field_count);
     if ($i == 0) {
        &dump_fields($stmt_mode, *fields, $field_count, ' { ');
     }
@@ -468,16 +489,12 @@ sub dump_line {
 }
 
 sub Getline2 {
-    &Pick('',@_);
+    my ($name, $pipe) = @_;
+    my ($getline_ok, $fh);
+    open($fh,$name.$pipe) unless $opened{$name}++;
     if ($getline_ok = (($_ = <$fh>) ne '')) {
        chomp;  # strip record separator
        @Fld = split(' ', $_, -1);
     }
     $_;
 }
-
-sub Pick {
-    local($mode,$name,$pipe) = @_;
-    $fh = $name;
-    open($name,$mode.$name.$pipe) unless $opened{$name}++;
-}
diff --git a/src/test/performance/runtests.pl b/src/test/performance/runtests.pl
index 1d0c53d..dc63f48 100755
--- a/src/test/performance/runtests.pl
+++ b/src/test/performance/runtests.pl
@@ -1,16 +1,20 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
 #
 # Accepts one argument - DBMS name (pgsql, ...) and initializes
 # global variable $TestDBMS with this name.
 #
 
 # Where to run tests
-$DBNAME = 'perftest';
+my $DBNAME = 'perftest';
 
 # This describtion for all DBMS supported by test
 # DBMS_name => [FrontEnd, DestroyDB command, CreateDB command]
 
-%DBMS = (
+my %DBMS = (
 'pgsql' => ["psql -q -d $DBNAME", "destroydb $DBNAME", "createdb $DBNAME"]
 );
 
@@ -33,7 +37,7 @@ $DBNAME = 'perftest';
 # of queries. (Look at example in sqls/inssimple for MySQL - it gives 
 # an idea of what can be done for features unsupported by an DBMS.)
 #
-...@perftests = (
+my @perftests = (
 # It speed up things
 'connection.ntm',      'DB connection startup (no timing)',
 # Just connection startup time (echo "" | psql ... - for PgSQL)
@@ -63,20 +67,20 @@ $DBNAME = 'perftest';
 # It seems that nothing below need to be changed
 #
 
-$TestDBMS = $ARGV[0];
+my $TestDBMS = $ARGV[0];
 die "Unsupported DBMS $TestDBMS\n" if !exists $DBMS{$TestDBMS};
 
-$FrontEnd = $DBMS{$TestDBMS}[0];
-$DestroyDB = $DBMS{$TestDBMS}[1];
-$CreateDB = $DBMS{$TestDBMS}[2];
+my $FrontEnd = $DBMS{$TestDBMS}[0];
+my $DestroyDB = $DBMS{$TestDBMS}[1];
+my $CreateDB = $DBMS{$TestDBMS}[2];
 
 print "(Re)create DataBase $DBNAME\n";
 
 `$DestroyDB`;          # Destroy DB
 `$CreateDB`;           # Create DB
 
-$ResFile = "Results.$TestDBMS";
-$TmpFile = "Tmp.$TestDBMS";
+my $ResFile = "Results.$TestDBMS";
+my $TmpFile = "Tmp.$TestDBMS";
 
 open (SAVEOUT, ">&STDOUT");
 open (STDOUT, ">/dev/null") or die;
@@ -84,11 +88,12 @@ open (SAVEERR, ">&STDERR");
 open (STDERR, ">$TmpFile") or die;
 select (STDERR); $| = 1;
 
-for ($i = 0; $i <= $#perftests; $i++)
+for (my $i = 0; $i <= $#perftests; $i++)
 {
-       $test = $perftests[$i];
+       my $test = $perftests[$i];
+    my $XACTBLOCK;
        ($test, $XACTBLOCK) = split (/ /, $test);
-       $runtest = $test;
+       my $runtest = $test;
        if ( $test =~ /\.ntm/ )
        {
                # 
@@ -130,8 +135,9 @@ open (RESF, ">$ResFile") or die;
 
 while (<TMPF>)
 {
-       $str = $_;
-       ($test, $rtime) = split (/:/, $str);
+       my $str = $_;
+       my ($test, $rtime) = split (/:/, $str);
+    my ($tmp, $rest);
        ($tmp, $rtime, $rest) = split (/[       ]+/, $rtime);
        print RESF "$test: $rtime\n";
 }
diff --git a/src/tools/version_stamp.pl b/src/tools/version_stamp.pl
index e99d2c3..21c04f7 100755
--- a/src/tools/version_stamp.pl
+++ b/src/tools/version_stamp.pl
@@ -1,4 +1,7 @@
-#! /usr/bin/perl -w
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
 
 #################################################################
 # version_stamp.pl -- update version stamps throughout the source tree
@@ -22,11 +25,13 @@
 
 # Major version is hard-wired into the script.  We update it when we branch
 # a new development version.
-$major1 = 8;
-$major2 = 4;
+my $major1 = 8;
+my $major2 = 4;
+my ($dotneeded, $numericminor, $majorversion, $fullversion,
+    $numericversion, $padnumericversion, $aconfver, $fixedfiles);
 
 # Validate argument and compute derived variables
-$minor = shift;
+my $minor = shift;
 defined($minor) || die "$0: missing required argument: minor-version\n";
 
 if ($minor =~ m/^\d+$/) {
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to