What the other fine monks hath said, plus the following: if you've got a simple list of variable size, you should be thinking "array." It's much less error-prone to let the program do your repetition for you, instead of manually typing in every line. For all we know, you left off a ; or a quote in one of those lines, or the line you've added (re-emphasize the 'for all we know' part =) and that's the source of your trouble. Compare:
# OK, I'm a bit of a Standards freak, but you get my point =)
print "<select name='reason'>\n";
foreach my $option (@options) {
# make sure line containing only dashes is selected
if ( $option =~ /^-+$/ ) {
print "<option selected='selected'>";
} else {
print "<option>";
}
print "$option</option>\n";
}
Now of course that forces you to set up the array beforehand, but that's not very difficult either:
my @options = ();
while (<DATA>) {
chomp;
push @options, $_;
}
# rest of program here, at the very end
__DATA__
-----------------------------------------
Deposits
PPV Dispute
...
Anyhow, just a kind of general programming note for the future, a good way of reducing bugs is to let the computer repeat stuff for you instead of doing it yourself.
HTH
If not P, what? Q maybe?
"Sidney Morgenbesser"
-
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.