Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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:

  • What sort of input is your script using? (a small sample, please)
  • What output do you want?
  • What output are you actually getting?

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.

Second, turn on warnings. If you are using a shebang line, add a -w to the shebang line:

#!/usr/bin/perl -w

If you are using Perl version 5.6 or better (I think that's when it was introduced), you can add "use warnings; to your code.

Just turning on warnings in your code produced some interesting information:

C:\temp>perl -wc index.pl Name "main::ccdrive" used only once: possible typo at index.pl lin +e 4. Name "main::name" used only once: possible typo at index.pl line 6 +8. Name "main::rephash" used only once: possible typo at index.pl lin +e 158. index.pl syntax OK

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.

The first warning refers to this line:

$ccdrive = $ENV{CC_DEFAULT_DRIVE};

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?

The second warning refers to this:

$name=$hash{"Tag"};

Later, you have the following statement twice: push(@vobs, $vobname);. Since $vobname is not initialized anywhere, perhaps the initial assignment should have been to $vobname instead?

The third warning is what may be causing your issue. It refers to the following line:

print TFILE2 "<font color=\"$rephash($ABC[$idx])\"><td> $ABC[$idx] +&nbsp </td> ";

Even though you've already declared a %rephash, it's not going to get recognized here because you need curly braces instead of parentheses. Also, &nbsp; needs a semicolon at the end. Here's a revision of that line:

print TFILE2 "<font color=\"$rephash{$ABC[$idx]}\"><td> $ABC[$idx] +&nbsp; </td>";

In a similar, previous line, you have an error that's not reported:

print TFILE2 "<font color=\$rephash{$replica}\> <td> $rephash{$rep +lica} $DEF[$idx]&nbsp</td>";

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:

print TFILE2 "<font color=\"$rephash{$replica}\"> <td> $rephash{$r +eplica} $DEF[$idx]&nbsp;</td>";

Hope this helps.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to (Ovid) Re: Desperatly seeking the wisdom of the Monks by Ovid
in thread Problem with while loop by Hopeless

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-03-29 06:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found