If you are looking for code in general, I would count ";" and give ";\n"; a very,very high ranking - that is very unusual for normal English text - just a couple of those is a "red flag" for not plain text. I would guess that two lines like that is a score of 99.999999. For Perl, look for Perl style comments perhaps ';' followed by '#.*\n'. Not sure what you are wanting.
Detecting that there is some significant code (5+lines or so) on the page should be easy. Guessing that Perl is part of it probably also (as opposed to C or Java). Extracting the exact lines that are Perl is going to be pretty darn hard.