memo.xight.org

日々のメモ

chalow Google Local Plug-in

Source

### Google Local Plug-in
# usage: {{google_local('what','where')}}
sub google_local {
	my ($what,$where) = @_;
	my $prefix = q(http://local.google.co.jp);

	my $what_enc = q();
	$what_enc = Jcode->new($what)->utf8;
	$what_enc =~ s/([^0-9a-z_ ])/'%'.unpack('H2', $1)/gei;
	$what_enc =~ s/\s/+/g;

	my $where_enc = q();
	$where_enc = Jcode->new($where)->utf8;
	$where_enc =~ s/([^0-9a-z_ ])/'%'.unpack('H2', $1)/gei;
	$where_enc =~ s/\s/+/g;

	my $ret  = qq(<a href="$prefix/local?q=$what_enc&near=$where_enc" title="Google Local - $where の $what">);
	   $ret .= qq(Google Local - $where の $what);
	   $ret .= qq(</a>);
	return $ret;
}