Question: I have a menu that is dynamically created. When the user selects a value, I need to get that value and use it for a query statement. This is not a form, just a menu on the page.

I have:

```
<select name="topic" id="topic">
          <option value="optiont" selected="selected">Select topic...</option>
          <?php
           while ($row = mysqli_fetch_array($sql))
          {
            echo "<option value=\"optiont$count\" name=\topic[]\">" . $row['topic'] . "</option>";
            $count++;
          }
          ?>
        </select>

```

I want to know which option is selected. How can I do this??

Answer: 
The problem is that you've only read in one line at a time. Why don't you read in the entire file and match against that.

```
my $file;
{
    local $/;
    $file = <FILE>;
}

```
If you absolutely have to do this, you could try setting the newline separator to undef:

```
#!/usr/bin/perl
use warnings;
use strict;

my $infile = 'in.txt';
open my $input, '<', $infile or die "Can't open to $infile: $!";

my $reserch_interests;
$/=undef;
while(<$input>){
        if($_ =~ /(Research Interests)/){
            $reserch_interests = $1;
                if($_=~ m/<p>(.*)<\/p>/){
                        print "Title: $reserch_interests\nInterests: $1\n";
                }
        }

}

```

Prints:

```
Title: Research Interests
Interests: Data mining, databases, information retrieval

```