my $value = param('name');#the value passed from the webpage my %data = (); my @fields = split(/\t/, ); my $row; my $id; my $course; chomp @fields; my @records; my @course; while() { chomp; my @row = split(/\t/); if ($row[0] eq $value) { ($id, $course) = split (/\t/); my %data; #then put the row into a hash. @data{@fields} = @row; push @records, \%data; } } close (FILE); for my $ref (@records){ my %data = %$ref; print ul( map { ul("$course") } keys %data);