perl

文字関連

■外部入力がutf8以外の場合の処理 文字コードを判別 utf8以外なら sjis⇒内部文字列⇒utf8の順に変換 use Encode::Guess qw/euc-jp shift-jis/; $enc=guess_encoding($shop_name); if ($enc->name ne 'utf8') { save_debugfile("文字コード:".$enc->name." か…

スクリプト

■■フォームパラメータ取得 ■GET $ENV{'QUERY_STRING'} を&で分解し=で分解し、URLデコード■POST read (STDIN, $PostData, $ENV{'CONTENT_LENGTH'}); を&で分解し=で分解し、URLデコード ■区別の仕方 $ENV{'REQUEST_METHOD'} = POST or GET で取得■…

DB

■mysql接続 use DBI qw(:sql_types); $dbh = DBI->connect('DBI:mysql:データベース名:ホスト名:ポート','ユーザーID','パス'); $dbh->do("set names utf8"); // クライアントの文字セット $sth = $dbh->prepare("select * from t1 where id=? and name=?"); $sth->…

モジュール確認

■モジュール一覧表示 find `perl -e 'print "@INC"'` -name '*.pm' -print ■特定のモジュール find `perl -e 'print "@INC"'` -name '*.pm' -print | grep Base64 ■CPANでPerlライブラリをインストール # perl -MCPAN -e shell 例 cpan> install SOAP::Lite …

hash

use Digest::SHA 'sha512_hex';my $sha1_sum = sha512_hex('abcde');

perl

とほほ ttp://www.tohoho-web.com/wwwperl.htm ■実行 基本www/cgi-binで実行可能になっている ドキュメントルート以下で実行するには httpd.conf に ExecCGIを追加 Options Indexes FollowSymLinks ExecCGIAddHandler cgi-script .cgiパーミッションは755…