# get drive while () { ++$counter; print "$counter\n"; if (/src=\"(.)\:\\/) { $original_drive_letter = $1; last; # exit the while loop now } } close PLAY;