Use strict & warnings. Fix several minor bugs uncovered by it.
Semantics of assigning to $[ changed in Perl 5, and its use is `highly discouraged'. Programs obviously assumed $[ affects all arrays, but it doesn't in Perl 5. If these programs ever worked, then certainly not with Perl 5. Remove the assignments and shift indexes accordingly.
This commit is contained in:
parent
dfb337891d
commit
759d3185ad
5 changed files with 76 additions and 56 deletions
|
@ -11,6 +11,11 @@
|
|||
# to check which Empire commands need to be documented.
|
||||
#
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my ($com, @list, @obsolete, @Commands);
|
||||
|
||||
open(LIST, "<player.list") || die "Can't read player.list\n";
|
||||
|
||||
while(<LIST>) {
|
||||
|
@ -60,10 +65,10 @@ while (<LS>) {
|
|||
close LS;
|
||||
|
||||
print "In list but not Commands:\n";
|
||||
for $l (@list) {
|
||||
for my $l (@list) {
|
||||
print " $l\n" unless grep (/^$l$/, @Commands);
|
||||
}
|
||||
print "In Commands but not list:\n";
|
||||
for $c (@Commands) {
|
||||
for my $c (@Commands) {
|
||||
print " $c\n" unless grep(/^$c$/, @list) || grep(/^$c$/, @obsolete);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/usr/local/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
$[ = 1; # set array base to 1
|
||||
my (@Fld, $str, @a);
|
||||
|
||||
line: while (<>) {
|
||||
chop; # strip record separator
|
||||
|
@ -9,17 +11,17 @@ line: while (<>) {
|
|||
|
||||
procline:
|
||||
if (/^\.TH/) {
|
||||
$str=$Fld[3];
|
||||
for ($i=4;$i <= $#Fld; $i++) {
|
||||
$str=$Fld[2];
|
||||
for (my $i=3; $i <= $#Fld; $i++) {
|
||||
$str .= " " . $Fld[$i];
|
||||
}
|
||||
$str = &htmlify($str);
|
||||
printf("<title>%s : %s</title><h1>%s : %s</h1>\n",
|
||||
$Fld[2],$str,$Fld[2], $str);
|
||||
$Fld[1], $str, $Fld[1], $str);
|
||||
next line;
|
||||
}
|
||||
|
||||
if (/^\.SY/) {
|
||||
if (/^\.SY../) {
|
||||
# $i = $_ =~ "\"" && ($RLENGTH = length($&), $RSTART = length($`)+1);
|
||||
# $str = substr($_, $i + 1, length($_) - $i - 1);
|
||||
$str = substr($_,5);
|
||||
|
@ -28,13 +30,13 @@ procline:
|
|||
next line;
|
||||
}
|
||||
|
||||
if (/^\.EX/) {
|
||||
if (/^\.EX../) {
|
||||
$str = substr($_, 5);
|
||||
printf "<br><samp>[##:##] </samp><kbd>%s</kbd><p>\n", &htmlify($str);
|
||||
next line;
|
||||
}
|
||||
|
||||
if (/^\.L/) {
|
||||
if (/^\.L../) {
|
||||
$str = substr($_, 4);
|
||||
printf "<h2>%s</h2>\n", &htmlify($str);
|
||||
next line;
|
||||
|
@ -48,8 +50,8 @@ procline:
|
|||
if (/^\.SA/) {
|
||||
@a = split('[: ",.]+');
|
||||
|
||||
printf("See also : %s\n",&anchor($a[3]) );
|
||||
for ($i = 4; $i <= $#a ; ($i)++) {
|
||||
printf("See also : %s\n",&anchor($a[2]) );
|
||||
for (my $i = 3; $i <= $#a ; ($i)++) {
|
||||
printf(", %s\n",&anchor($a[$i]));
|
||||
}
|
||||
|
||||
|
@ -58,7 +60,7 @@ procline:
|
|||
@a = split('[: ,.]+');
|
||||
@Fld = split(' ', $_, 9999);
|
||||
if (/^\./) { goto procline; }
|
||||
for ($i = 1; $i <= $#a ; ($i)++) {
|
||||
for (my $i = 0; $i <= $#a ; ($i)++) {
|
||||
printf(", %s\n",&anchor($a[$i]));
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +73,8 @@ procline:
|
|||
if (/^(See also|See Also|see also)/) {
|
||||
@a = split('[: ,.]+');
|
||||
|
||||
printf("See also : %s\n",&anchor($a[3]) );
|
||||
for ($i = 4; $i <= $#a ; ($i)++) {
|
||||
printf("See also : %s\n",&anchor($a[2]) );
|
||||
for (my $i = 3; $i <= $#a ; ($i)++) {
|
||||
printf(", %s\n",&anchor($a[$i]));
|
||||
}
|
||||
|
||||
|
@ -81,7 +83,7 @@ procline:
|
|||
@a = split('[: ,.]+');
|
||||
@Fld = split(' ', $_, 9999);
|
||||
if (/^\./) { goto procline; }
|
||||
for ($i = 1; $i <= $#a ; ($i)++) {
|
||||
for (my $i = 0; $i <= $#a ; ($i)++) {
|
||||
printf(", %s\n",&anchor($a[$i]));
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +106,7 @@ procline:
|
|||
|
||||
sub anchor {
|
||||
local ($_) = @_;
|
||||
local(@file,$file);
|
||||
my (@file,$file);
|
||||
$file = $_ . ".t";
|
||||
# if (-r $file) {
|
||||
if (1) {
|
||||
|
@ -113,9 +115,9 @@ sub anchor {
|
|||
} else {
|
||||
@file = <$_*t>;
|
||||
if (@file) {
|
||||
warn "Expanding $_ to $file[$[]\n";
|
||||
$file[$[] =~ s/.t$/.html/;
|
||||
return ("<a href=\"$file[$[]\">$_</a>");
|
||||
warn "Expanding $_ to $file[0]\n";
|
||||
$file[0] =~ s/.t$/.html/;
|
||||
return ("<a href=\"$file[0]\">$_</a>");
|
||||
} else {
|
||||
warn "Unable to link $_\n";
|
||||
return ( "<em>$_</em>");
|
||||
|
@ -134,15 +136,15 @@ sub htmlify {
|
|||
s/\>/>/g;
|
||||
while (@a = /(\\\*Q)([A-Za-z0-9\-\.]+)(\\\*U)/) {
|
||||
/(\\\*Q)([A-Za-z\-]+)(\\\*U)/;
|
||||
$_ = $` . &anchor($a[2]) . $';
|
||||
$_ = $` . &anchor($a[1]) . $';
|
||||
}
|
||||
while (@a = /(\\\*Q)(\"info )([A-Za-z0-9\-\.]+)(\\\*U)/) {
|
||||
/(\\\*Q)(\"info )([\w\-\.]+)(\\\*U)/;
|
||||
$_ = $` . "\"info " . &anchor($a[3]) . $';
|
||||
$_ = $` . "\"info " . &anchor($a[2]) . $';
|
||||
}
|
||||
while (@a = /(\"info )([A-Za-z0-9\-\.]+)/) {
|
||||
/(\"info )([\w\-\.]+)/;
|
||||
$_ = $` . "\"info " . &anchor($a[2]) . $';
|
||||
$_ = $` . "\"info " . &anchor($a[1]) . $';
|
||||
}
|
||||
s/\\\*Q/<em>/g;
|
||||
s/\\\*U/<\/em>/g;
|
||||
|
|
18
info/info.pl
18
info/info.pl
|
@ -84,6 +84,12 @@
|
|||
# flush_subj Print a row of Subjects to TOP
|
||||
# error Print an integrity error to STDERR and exit with code 1.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our (@dirs, $dir, $filename, %filedir, @Subjects, $type, %desc, %level);
|
||||
our (%see_also, %subject, %largest, $subj, @rowsubj, @colsubj, @subj);
|
||||
|
||||
eval("require 5"); # Test for perl version 5
|
||||
die "info.pl requires version 5 of perl.\n" if $@;
|
||||
|
||||
|
@ -208,9 +214,9 @@ sub parse_file {
|
|||
|
||||
# Create %subject from %see_also
|
||||
sub parse_see_also {
|
||||
local (@see_also) = split(/, /, $see_also{$filename});
|
||||
my (@see_also) = split(/, /, $see_also{$filename});
|
||||
local ($dir) = $filedir{$filename};
|
||||
local ($found); # Does this item belong to any Subject?
|
||||
my ($found); # Does this item belong to any Subject?
|
||||
|
||||
for (@see_also) {
|
||||
if (!(defined $filedir{$_})) { # is this entry a subject?
|
||||
|
@ -225,6 +231,7 @@ sub parse_see_also {
|
|||
# Add a new entry to %subject and possibly to %largest
|
||||
sub set_subject {
|
||||
$subject{$_}{$dir} .= "$filename\n";
|
||||
$largest{$_} = "" unless defined $largest{$_};
|
||||
$largest{$_} = $filename if length $filename > length $largest{$_};
|
||||
$largest{$_} = $dir if length $dir > length $largest{$_};
|
||||
}
|
||||
|
@ -283,8 +290,9 @@ EOF
|
|||
$subj eq 'TOP' || grep (/^$subj$/, @rowsubj);
|
||||
}
|
||||
|
||||
for $i (0..2) {
|
||||
for ($j = $i; $j <= $#rowsubj; $j += 3) {
|
||||
my $k = 0;
|
||||
for my $i (0..2) {
|
||||
for (my $j = $i; $j <= $#rowsubj; $j += 3) {
|
||||
$colsubj[$j] = $rowsubj[$k++];
|
||||
}
|
||||
}
|
||||
|
@ -316,7 +324,7 @@ sub flush_subj {
|
|||
|
||||
# Print an integrity error message and exit with code 1
|
||||
sub error {
|
||||
local ($error) = @_;
|
||||
my ($error) = @_;
|
||||
|
||||
print STDERR "Error on line $. of $filedir{$filename}/$filename.t:\n";
|
||||
print STDERR "$_";
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#!/usr/local/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
printf("<pre>\n");
|
||||
while (<>) {
|
||||
s/([\w\.\-]+)\.html/<a href=\"$1.html\">$1<\/a>/g;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#!/usr/local/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
$[ = 1; # set array base to 1
|
||||
$dome = 0;
|
||||
my $dome = 0;
|
||||
my (@Fld, $str, @a);
|
||||
|
||||
line: while (<>) {
|
||||
chop; # strip record separator
|
||||
|
@ -10,17 +12,17 @@ line: while (<>) {
|
|||
|
||||
procline:
|
||||
if (/^\.TH/) {
|
||||
$str=$Fld[3];
|
||||
for ($i=4;$i <= $#Fld; $i++) {
|
||||
$str=$Fld[2];
|
||||
for (my $i=3; $i <= $#Fld; $i++) {
|
||||
$str .= " " . $Fld[$i];
|
||||
}
|
||||
$str = &htmlify($str);
|
||||
printf("<title>%s : %s</title><h1>%s : %s</h1>\n",
|
||||
$Fld[2],$str,$Fld[2], $str);
|
||||
$Fld[1], $str, $Fld[1], $str);
|
||||
next line;
|
||||
}
|
||||
|
||||
if (/^\.SY/) {
|
||||
if (/^\.SY../) {
|
||||
# $i = $_ =~ "\"" && ($RLENGTH = length($&), $RSTART = length($`)+1);
|
||||
# $str = substr($_, $i + 1, length($_) - $i - 1);
|
||||
$str = substr($_,5);
|
||||
|
@ -29,7 +31,7 @@ procline:
|
|||
next line;
|
||||
}
|
||||
|
||||
if (/^\.EX/) {
|
||||
if (/^\.EX../) {
|
||||
$str = substr($_, 5);
|
||||
printf "<br><samp>[##:##] </samp><kbd>%s</kbd><p>\n", &htmlify($str);
|
||||
next line;
|
||||
|
@ -37,8 +39,8 @@ procline:
|
|||
|
||||
if (/^\.L/) {
|
||||
@a = split('[: ",.]+');
|
||||
$str = &anchor($a[3]);
|
||||
$str = ("$str $a[4]");
|
||||
$str = &anchor($a[2]);
|
||||
$str = ("$str $a[3]") if defined $a[3];
|
||||
printf("<br>%s\n", $str);
|
||||
next line;
|
||||
}
|
||||
|
@ -53,9 +55,9 @@ procline:
|
|||
if ($dome == 1) {
|
||||
@a = split('[: ",.]+');
|
||||
|
||||
for ($i = 2; $i <= $#a ; ($i)++) {
|
||||
for (my $i = 1; $i <= $#a ; ($i)++) {
|
||||
printf("%s",&anchor($a[$i]));
|
||||
for ($j = 0; $j < 20 - length($a[$i]); $j++) {
|
||||
for (my $j = 0; $j < 20 - length($a[$i]); $j++) {
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
|
@ -65,9 +67,9 @@ procline:
|
|||
@a = split('[: ,.]+');
|
||||
@Fld = split(' ', $_, 9999);
|
||||
if (/^\./) { goto procline; }
|
||||
for ($i = 2; $i <= $#a ; ($i)++) {
|
||||
for (my $i = 1; $i <= $#a ; ($i)++) {
|
||||
printf("%s",&anchor($a[$i]));
|
||||
for ($j = 0; $j < 20 - length($a[$i]); $j++) {
|
||||
for (my $j = 0; $j < 20 - length($a[$i]); $j++) {
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
|
@ -79,8 +81,8 @@ procline:
|
|||
if (/^\.SA/) {
|
||||
@a = split('[: ",.]+');
|
||||
|
||||
printf("See also : %s\n",&anchor($a[3]) );
|
||||
for ($i = 4; $i <= $#a ; ($i)++) {
|
||||
printf("See also : %s\n",&anchor($a[2]) );
|
||||
for (my $i = 3; $i <= $#a ; ($i)++) {
|
||||
printf(", %s\n",&anchor($a[$i]));
|
||||
}
|
||||
|
||||
|
@ -89,7 +91,7 @@ procline:
|
|||
@a = split('[: ,.]+');
|
||||
@Fld = split(' ', $_, 9999);
|
||||
if (/^\./) { goto procline; }
|
||||
for ($i = 1; $i <= $#a ; ($i)++) {
|
||||
for (my $i = 0; $i <= $#a ; ($i)++) {
|
||||
printf(", %s\n",&anchor($a[$i]));
|
||||
}
|
||||
}
|
||||
|
@ -102,8 +104,8 @@ procline:
|
|||
if (/^(See also|See Also|see also)/) {
|
||||
@a = split('[: ,.]+');
|
||||
|
||||
printf("See also : %s\n",&anchor($a[3]) );
|
||||
for ($i = 4; $i <= $#a ; ($i)++) {
|
||||
printf("See also : %s\n",&anchor($a[2]) );
|
||||
for (my $i = 3; $i <= $#a ; ($i)++) {
|
||||
printf(", %s\n",&anchor($a[$i]));
|
||||
}
|
||||
|
||||
|
@ -112,7 +114,7 @@ procline:
|
|||
@a = split('[: ,.]+');
|
||||
@Fld = split(' ', $_, 9999);
|
||||
if (/^\./) { goto procline; }
|
||||
for ($i = 1; $i <= $#a ; ($i)++) {
|
||||
for (my $i = 0; $i <= $#a ; ($i)++) {
|
||||
printf(", %s\n",&anchor($a[$i]));
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +137,7 @@ procline:
|
|||
|
||||
sub anchor {
|
||||
local ($_) = @_;
|
||||
local(@file,$file);
|
||||
my (@file, $file);
|
||||
$file = $_ . ".t";
|
||||
# if (-r $file) {
|
||||
if (1) {
|
||||
|
@ -144,9 +146,9 @@ sub anchor {
|
|||
} else {
|
||||
@file = <$_*t>;
|
||||
if (@file) {
|
||||
warn "Expanding $_ to $file[$[]\n";
|
||||
$file[$[] =~ s/.t$/.html/;
|
||||
return ("<a href=\"$file[$[]\">$_</a>");
|
||||
warn "Expanding $_ to $file[0]\n";
|
||||
$file[0] =~ s/.t$/.html/;
|
||||
return ("<a href=\"$file[0]\">$_</a>");
|
||||
} else {
|
||||
warn "Unable to link $_\n";
|
||||
return ( "<em>$_</em>");
|
||||
|
@ -165,15 +167,15 @@ sub htmlify {
|
|||
s/\>/>/g;
|
||||
while (@a = /(\\\*Q)([A-Za-z0-9\-\.]+)(\\\*U)/) {
|
||||
/(\\\*Q)([A-Za-z\-]+)(\\\*U)/;
|
||||
$_ = $` . &anchor($a[2]) . $';
|
||||
$_ = $` . &anchor($a[1]) . $';
|
||||
}
|
||||
while (@a = /(\\\*Q)(\"info )([A-Za-z0-9\-\.]+)(\\\*U)/) {
|
||||
/(\\\*Q)(\"info )([\w\-\.]+)(\\\*U)/;
|
||||
$_ = $` . "\"info " . &anchor($a[3]) . $';
|
||||
$_ = $` . "\"info " . &anchor($a[2]) . $';
|
||||
}
|
||||
while (@a = /(\"info )([A-Za-z0-9\-\.]+)/) {
|
||||
/(\"info )([\w\-\.]+)/;
|
||||
$_ = $` . "\"info " . &anchor($a[2]) . $';
|
||||
$_ = $` . "\"info " . &anchor($a[1]) . $';
|
||||
}
|
||||
s/\\\*Q/<em>/g;
|
||||
s/\\\*U/<\/em>/g;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue