P
Peter Stokes
I'm trying to use a list, created from an array, to build a dropdown
list in a web page form.
I start with a flatfile database, pipe delimited. The first field is
the county, then the name, then other info. The dropdown list is to be
of the counties.
I've got:
open (INFILE, "db1.dat");
while (<INFILE>) {
@things = split /\|/;
@counties = splice(@things,0,1);
This is fine, it generates my list, but of course it has duplicates in
it. So to get rid of the duplicates I've got:
@counties = grep( ( ($h{$_}++ < 1) || 0 ), @counties );
Which does indeed get rid of the duplicates.
This is where I'm having the problem. If I now:
print @counties;
I get a solid line of text. I need to format this. If I:
print "<option value=\"@counties\">@counties\n";
I get a list which includes formatting on the lines that have been
removed, so the result looks like:
<option value="Berkshire">Berkshire
<option value="Dorset">Dorset
<option value="">
<option value="">
<option value="Gloucestershire">Gloucestershire
....and so on.
Please can anyone suggest where I'm going wrong.
Thanks
Peter Stokes
list in a web page form.
I start with a flatfile database, pipe delimited. The first field is
the county, then the name, then other info. The dropdown list is to be
of the counties.
I've got:
open (INFILE, "db1.dat");
while (<INFILE>) {
@things = split /\|/;
@counties = splice(@things,0,1);
This is fine, it generates my list, but of course it has duplicates in
it. So to get rid of the duplicates I've got:
@counties = grep( ( ($h{$_}++ < 1) || 0 ), @counties );
Which does indeed get rid of the duplicates.
This is where I'm having the problem. If I now:
print @counties;
I get a solid line of text. I need to format this. If I:
print "<option value=\"@counties\">@counties\n";
I get a list which includes formatting on the lines that have been
removed, so the result looks like:
<option value="Berkshire">Berkshire
<option value="Dorset">Dorset
<option value="">
<option value="">
<option value="Gloucestershire">Gloucestershire
....and so on.
Please can anyone suggest where I'm going wrong.
Thanks
Peter Stokes