in reply to homework: Simple matching and sorting

Or even shorter:
use strict; my @lines=grep(/;/, <DATA>); print pop @lines; __DATA__ This is not the right line This OK, it contains a ; This is no good either Hey, a ; in this line! Drop this.
It is shorter, but it uses more memory if the text file is large as it reads in all lines of the file and keeps all lines with a ';' only to print the last line.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law