note
Ovid
<p>[Hopeless], yes, the code is a mess, but the situation is not as hopeless as your nick would imply. Before we can help you, we need to know what you are looking for. A quick check shows that your code compiles cleanly, so it's not an obvious syntax error. What we need to know is:</p>
<ul>
<li>What sort of input is your script using? (a small sample, please)</li>
<li>What output do you want?</li>
<li>What output are you actually getting?</li>
</ul>
<p>Without clear information like that, most of the advice that we can offer is a shot in the dark. However, there are two pieces of advice that I can give right now. First, use [strict]. All competent Perl programmers will tell you that for a program of significant size, you should almost always be be using strict. Strict will allow you to catch a lot of the typos and other problems which might plague your code (and it did, when I used it for your program.</p>
<p>Second, turn on warnings. If you are using a shebang line, add a -w to the shebang line:</p>
<code>
#!/usr/bin/perl -w
</code>
<p>If you are using Perl version 5.6 or better (I think that's when it was introduced), you can add "<tt>use warnings;</tt> to your code.</p>
<p>Just turning on warnings in your code produced some interesting information:</p>
<code>
C:\temp>perl -wc index.pl
Name "main::ccdrive" used only once: possible typo at index.pl line 4.
Name "main::name" used only once: possible typo at index.pl line 68.
Name "main::rephash" used only once: possible typo at index.pl line 158.
index.pl syntax OK
</code>
<p>As for the command line switches, -w enables warnings and -c tells Perl to compile the program without running it. This is a quick check to see if the program can even attempt to run.</p>
<p>The first warning refers to this line:</p>
<code>
$ccdrive = $ENV{CC_DEFAULT_DRIVE};
</code>
<p>Since that variable is not used anywhere else in the program, I wonder if this is part of a feature you have not yet implemented?</p>
<p>The second warning refers to this:</p>
<code>
$name=$hash{"Tag"};
</code>
<p>Later, you have the following statement twice: <code>push(@vobs, $vobname);</code>. Since $vobname is not initialized anywhere, perhaps the initial assignment should have been to $vobname instead?</p>
<p>The third warning is what may be causing your issue. It refers to the following line:</p>
<code>
print TFILE2 "<font color=\"$rephash($ABC[$idx])\"><td> $ABC[$idx]  </td> ";
</code>
<p>Even though you've already declared a <tt>%rephash</tt>, it's not going to get recognized here because you need curly braces instead of parentheses. Also, <tt>&nbsp;</tt> needs a semicolon at the end. Here's a revision of that line:</p>
<code>
print TFILE2 "<font color=\"$rephash{$ABC[$idx]}\"><td> $ABC[$idx] </td>";
</code>
<p>In a similar, previous line, you have an error that's not reported:</p>
<code>
print TFILE2 "<font color=\$rephash{$replica}\> <td> $rephash{$replica} $DEF[$idx] </td>";
</code>
<p>The problem there is that you put a backslash directly in front of the dollar sign. When you do that in a string, it tells Perl that you really wanted to print a dollar sign and didn't want the following variable interpolated. The following line is what you intended:</p>
<code>
print TFILE2 "<font color=\"$rephash{$replica}\"> <td> $rephash{$replica} $DEF[$idx] </td>";
</code>
<p>Hope this helps.</P>
<p>Cheers,<br />
<a href="/index.pl?node=Ovid&lastnode_id=1072">Ovid</a></p>
<p><small>Join the <a href="http://setiathome.ssl.berkeley.edu/stats/team/team_86606.html">Perlmonks Setiathome Group</a> or just click on the the link and check out our stats.</small></p>
121645
121645