2009-09-01から1ヶ月間の記事一覧

メール送信

#!/usr/bin/perl use strict; use warnings; use utf8; use Encode; use Date::Simple 'today'; use Email::Send; use Email::MIME::Creator; my $SUBJECT = '件名です'; my $FROM = 'from@example.jp'; my $TO = 'to@example.jp'; my $SMTP_SERVER = '192.1…

DateTime

#!/usr/bin/perl use strict; use warnings; use DateTime; my $dt = DateTime->now( time_zone => 'Asia/Tokyo' ); my $expire = $dt->add( months => 3 ); # 今日の3ヶ月後 print $expire->ymd, "\n"; printf "[%s] ", $dt->strftime('%Y-%m-%d %H:%M:%S')…

use English

#!/usr/bin/perl use strict; use warnings; use English '-no_match_vars'; $0 を $PROGRAM_NAME のように、特殊変数をわかりやすい変数名として使う。-no_match_varsで、正規表現時の $`, $&, $' を使わない。

オプション

#!/usr/bin/perl use strict; use warnings; use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; # standard-conforming behaviour our( $opt_v, $opt_h, $opt_a, ); getopts('vha:'); print "v: $opt_v\n" if ($opt_v); print "h: $opt_h\n" if ($…