Perl: taking text from a .txt file

How would i go about the following,

I open a text document with loads of text, about 150 lines

e.g. "Best Time: 02:55.88"

How would i get perl just to take the time and put into a variable but also be able to take any time like that from the file??

i've done this so far to open the document

opendir (FILE, "> c:\\My Documents\\times.txt" or die "Cant open: $!";

readdir FILE @readfile;
closedir FILE;

opendir/readdir is the wrong set of things to call for what you described. You want to "open" the file (I usually call it F if it's the only input file), then

while (<F>) {
    while (/\G(timepattern)/g) {
	print FILE $1, "\n"
    }
}

If you are supplying the file name on the command line, change "while (<F>)" to "while (<>)".

The inner while loop searches for all the substrings that match the regexp timepattern on an individual line. If you know there is at most one match for timepattern on a line, the inner "while" becomes "if (/(timepattern)/)". Constructing timepattern is a valuable enough skill that you should expend the effort to learn it on your own; see the perlre manpage. Or, as the textbooks say, it is left as an exercise for the reader.

thanks very much!