Created
December 31, 2014 03:03
-
-
Save magnolia-k/b556e358bfb6e5c6b3e5 to your computer and use it in GitHub Desktop.
perlの正式版のバージョンの一覧を作る
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.io.Source | |
object perlVersions extends App { | |
val perlVersionList = parsePerlVersions("http://www.cpan.org/src/5.0/") | |
perlVersionList.foreach(println) | |
def parsePerlVersions(url: String): List[String] = { | |
val html = Source.fromURL(url).mkString | |
val regexp = """<a href="perl-(5.(\d{1,2}).\d).tar.gz">.*?</a>""".r | |
for ( m <- regexp.findAllMatchIn(html).toList; | |
major = m.group(2) | |
if major.toInt % 2 == 0 | |
) | |
yield m.group(1).toString | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment