in reply to Removing leading and ending text?

Try this:
#!/usr/bin/perl -w use strict; my $string = <<"EOT"; <title>stuff</title> <br>Header</br> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> <br>Trailing Info EOT my ($wanted) = $string =~ /(<tr>.*<\/tr>)/s; print "$wanted\n";
Which gives:
<tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr>

The key here is the "s" modifier in the pattern match, which causes the whole string to be treated as a single line. See perlre for more info.

Update: I guess I should point out that if you happened to be parsing some html which had multiple tables, then this would fail because the .* would eat up everything between the first <tr> in the first table, and the final </tr> in the last table (but that is what you asked for). For anything other than basic parsing of html, you're much better going with one of the many modules available.

Cheers,
Darren :)