Summary
TripletaiL とは,Linux+Apache+MySQL+Perl環境で日本語のウェブアプリケーションを構築するためのオープンソースフレームワーク.
Reference
TL - Perlフレームワークhttp://tripletail.jp/
use Term::TtyRec::Player;
use FileHandle;
# $handle is any IO::* object
my $handle = FileHandle->new('file.tty');
my $player = Term::TtyRec::Player->new($handle);
# options can be set as hashref
my $player = Term::TtyRec::Player->new($handle, {
speed => 1, nowait => undef,
});
use lib 'path/to/lib';
use Foo;
use lib 'path/to/lib';
use Text::Iconv;
#!/usr/bin/perl
use CGI;
use Text::Iconv;
use CGI::Lite;
my $converter = Text::Iconv->new("UTF8", "EUC-JP");
my $cgi = new CGI;
my $new_query = q();
# パラメータが空の場合を考慮
if ($cgi->param('key')){
$new_query = $converter->convert($cgi->param('key'));
}
$uencode = url_encode($new_query);
print "Location: http://example.com/path/to/namazu2.cgi?key="."$uencode\n\n";
<form accept-charset="euc-jp">
</form>
Content-Type:multipart/alternative
Content-Type:text/plain
メールの内容 (テキスト)
Content-Type:text/html
メールの内容 (HTML)
Content-Type: multipart/mixed
Content-Type: multipart/alternative
Content-Type:text/plain
メールの内容 (テキスト)
Content-Type:text/html
メールの内容 (HTML)
Content-Type:image/gif
Content-Transfer-encoding:base64
(base64で符号化されたgifファイル)
Content-Type:multipart/related
Content-Type: multipart/alternative
Content-Type:text/plain
メールの内容 (テキスト)
Content-Type:text/html
メールの内容 (HTML)
Content-Type:image/gif
Content-Transfer-encoding:base64
Content-ID:<sample>
(base64で符号化されたgifファイル)
use HTTP::MobileAgent;
my $agent = HTTP::MobileAgent->new;
if ($agent->is_docomo){
# iモード
} elsif ($agent->is_ezweb){
# EZweb
} elsif ($agent->is_vodafone){
# Vodafone
}
#!/usr/bin/perl
use CGI;
use Template;
use HTTP::MobileAgent;
my $q = CGI->new;
my $agent = HTTP::MobileAgent->new;
my $tt = Template->new({ABSOLUTE => 1});
my $output;
# sample.htmlのagentパラメータへ
# HTTP::MobileAgentのインスタンスをセットする
$tt->process('/path/to/sample.html', {agent => $agent}, \$output) or die $Template::ERROR;
print $q->header(-charset=>'Shift_JIS');
print $output;
exit;
<html>
<body>
[% IF agent.is_docomo %]
iモード
[% ELSIF agent.is_ezweb %]
EZweb
[% ELSIF agent.is_vodafone %]
Vodafone Live!
[% ELSE %]
Non Mobile...
[% END %]
</body>
</html>
use Mail::Address::MobileJp;
if (is_imode($email)){
# @docomo.ne.jp
}elsif (is_ezweb($email)){
# @ezweb.ne.jp or @*.ezweb.ne.jp
}elsif (is_vodafone($email)){
# @jp-*.ne.jp or @*.vodafone.ne.jp
# (*にはd,h,t,c,k,r,n,s,qのみが適用となる)
}
use CGI;
use HTML::Entities::ImodePictogram;
my $q = CGI->new;
my $text = $q->param('text');
# EZwebの絵文字も削除対象にする
$HTML::Entities::ImodePictogram::ExtPictorgram_re .= '|[\xF3\xF4\xF6\xF7][\x40-\x7E\x80-\xFC]';
# iモード、EZwebの絵文字を削除
$text = remove_pictogram($text);
# Vodafoneの絵文字を削除
$text =~ s/\x1B\$(.+?)\x0F//g;
% mysqldump2email --conf /path/to/config.yaml
mysqldump:
command: /usr/bin/mysqldump
username: your-mysql-username
password: your-mysql-password
#host: localhost
zip:
command: /usr/bin/zip
# if encryption needed
#password: your-zip-password
mail:
from: user@example.com
to: user@example.com
route:
via: smtp
host: localhost:25
#route:
# via: sendmail
gspace:
enable: 0
directory: /
tmpdir: /tmp
#time_zone: Asia/Tokyo
# aptitude install libexpat-dev libgd2-dev
# cpan install GD
# cpan install GD::Barcode::QRcode
#!/usr/bin/perl
use strict;
use GD::Barcode::QRcode;
my $str = $ENV{'HTTP_REFERER'};
my $header = qq(Content-Type: image/png\n\n);
my $qr = GD::Barcode::QRcode->new($str,{ ECC => 'L', Version => 2, ModuleSize =>2,})->plot->png;
print $header,$qr;
exit;
<img src="path/to/qr.cgi" width="97" height="97" alt="QRcode" />
# cpan -i GD::Barcode::QRcode
#$oSelf->{Version} = $rhPrm->{Version} || 1;
$oSelf->{Version} = $rhPrm->{Version};
#!/usr/bin/perl
use strict;
use CGI;
use GD::Barcode::QRcode;
my $q = new CGI;
my $str = $q->param('q');
my $header = qq(Content-Type: image/png\n\n);
my $qr = GD::Barcode::QRcode->new($str)->plot->png;
print $header,$qr;
exit;