Perl

Perl CGI から MongoDB 内の Collection を参照する

前回の Perl による焼き直しw #!/perl/bin/perl -- use MongoDB; my $con = MongoDB::Connection -> new; my $col = $con -> test -> twitter; print << "HEADER"; Content-Type: text/html; charset=utf-8 Content-Language: ja <html> <head> <title>MongoDB 接続テスト</title> </head></html>

GD モジュールを利用した CGI

前にこんな CGI 書いたんです(OS は Windows、ActivePerl を C:\Perl 以下にインストール)。 #!/perl/bin/perl -- use GD; $im = new GD::Image -> new(100,100); $black = $im -> colorAllocate(0,0,0); $white = $im -> colorAllocate(255,255,255); $im -…

リストを利用して変数の中身を入れ替える

Perl では二つの変数 $x, $y があったとき ($x, $y) = ($y, $x); と書くだけで変数の中身を入れ替えることができる。