Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
phpのソースの最新バージョンを取得する
#!/usr/bin/env perl
use strict;
use warnings;
my $curl='curl';
sub php_latest {
my $release=shift;
my $atom=`$curl http://www.php.net/releases/feed.php`;
while( $atom=~m#<link rel="enclosure" title="([^"]+)" href="([^"]+)">#mg ) {
my($title,$href)=($1,$2);
if($title=~/^PHP (\Q$release.\E(?:\d{1,2})) \Q(tar.gz)\E/) { return $1 }
}
return undef;
}
my $phpver=php_latest(5.5);
system($curl,'--location','--max-redirs',3,'-o',"php-$phpver.tar.bz2",
"http://jp1.php.net/get/php-$phpver.tar.bz2/from/this/mirror");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment