[i7] stray "to say X" detector for I7

Maybe this has been done before? If so, apologies.

But this simple perl script picked off “dead end” say-text for me. In other words, stuff that I thought was in the game somewhere, but the player could not see it! This is a first-draft PERL script, but it helped me enough I thought I’d post it. Suggestions for improvement are welcome.

[code]open(A, “story.ni”);

while ($a=)
if ($a =~ /^to say/)
$b = $a; chomp($b); $b =~ s/^to say //g; $b =~ s/ of.//g; $b =~ s/:.//g;
$init{$b} = 1;


open(A, “story.ni”);

while ($a = )
if ($a !~ /[/) { next; }
$a =~ s/^[^[]//g;
@x = split (/[/, $a);
for (@x)
$_ =~ s/].
$_ =~ s/ of.*//g;
$said{$_} = 1;


foreach $q (sort keys %init)
if (!$said{$q}) { print “$q is not accessed.\n”; }

foreach $q (sort keys %said)
#print “$q is bracketed.\n”;

I’d be curious about other code-parsing utilities. Are they out there? Is my google-fu weak? Does anyone have suggestions for other tools?

I know I need all of these I can get, and having them leaves me less worried I forgot something silly.

Could you explain exactly what this Perl script is searching for?

No problem. Sorry, just whipped it up and forgot to document sufficiently–basically, it takes one pass through the file and records all instances of either

To say ($x):


To say ($x) of (some variables):

Then, it does a second pass through and looks for, in the code,

If it doesn’t find [$x for any value of x, it notes that value of $x. If it does, it ignores things.

The “init” hash tracks everything of the form “to say ($x)” and sets the hash value to 1. That’s not the greatest name, but init = initially found.

The “said” hash tracks everything of the form “[($x)” and sets the hash value to 1 if it is.

If init($x) = 1 and said($x) = 0, then we have a “to say X” but not a [X] or [X of] in the code.

I hope this is a decent explanation, but let me know if it should be clearer. The code could use sprucing up in a lot of ways, I would bet.