use Time::Timezone; use Time::CTime;
#!/usr/bin/perl
print &getDateTime('JST');
print &getDateTime('GMT');
print &getDateTime('PST');
sub getDateTime {
my $tz = shift;
use Time::Timezone qw (tz_offset);
use Time::CTime;
return strftime("%Y/%m/%d %R", gmtime(time + tz_offset($tz)));
}
1;
use Time::Timezone; use Time::CTime;
#!/usr/bin/perl
print &getDateTime('JST');
print &getDateTime('GMT');
print &getDateTime('PST');
sub getDateTime {
my $tz = shift;
use Time::Timezone qw (tz_offset);
use Time::CTime;
return strftime("%Y/%m/%d %R", gmtime(time + tz_offset($tz)));
}
1;
use Unicode::Japanese; # C コンパイラが使えれば XS も利用できる
#!/usr/bin/perl
my $text = 'テスト';
my $output = print4i(¥$text);
sub print4i {
my $str = shift;
use Unicode::Japanese;
$$str = Unicode::Japanese->new($$str, 'sjis-imode')->z2h->sjis_imode
if $isiMode;
print $$str;
}
use Unicode::Japanese; # C コンパイラが使えれば XS も利用できる
#!/usr/bin/perl
my $text = 'テスト';
my $output = print4i(¥$text);
sub print4i {
my $str = shift;
use Unicode::Japanese;
$$str = Unicode::Japanese->new($$str, 'sjis-imode')->z2h->sjis_imode
if $isiMode;
print $$str;
}
use DBI; # 要 DBD::MySQL
#!/usr/bin/perl
use DBI;
$TABLE_NAME = 'テーブル名';
$DB = DBI->connect(...);
my $sth = $DB->prepare(qq|INSERT INTO $TABLE_NAME (
`id`,
`mimetype`,
`object`,
`created`,
`updated`
)
VALUES (?, ?, ?, ?, ?)|
);
$sth->execute(
$id,
$miemetype,
$object,
$NOW,
$NOW
);
$DB->disconnect();
1;
use DBI; # 要 DBD::MySQL
#!/usr/bin/perl
use DBI;
$TABLE_NAME = 'テーブル名';
$DB = DBI->connect(...);
my $sth = $DB->prepare(qq|INSERT INTO $TABLE_NAME (
`id`,
`mimetype`,
`object`,
`created`,
`updated`
)
VALUES (?, ?, ?, ?, ?)|
);
$sth->execute(
$id,
$miemetype,
$object,
$NOW,
$NOW
);
$DB->disconnect();
1;
なし
#!/usr/bin/perl
sub getEmails {
my $text = shift;
my @emails;
my $email_regex =
q{(?:[^(¥040)<:>@,;:".¥¥¥¥¥[¥]¥000-¥037¥x80-¥xff]+(?![^(¥040)<:>@,;:".¥¥¥¥}
. q{¥[¥]¥000-¥037¥x80-¥xff])|"[^¥¥¥¥¥x80-¥xff¥n¥015"]*(?:¥¥¥¥[^¥x80-¥xff][}
. q{^¥¥¥¥¥x80-¥xff¥n¥015"]*)*")(?:¥.(?:[^(¥040)<:>@,;:".¥¥¥¥¥[¥]¥000-¥037¥x}
. q{80-¥xff]+(?![^(¥040)<:>@,;:".¥¥¥¥¥[¥]¥000-¥037¥x80-¥xff])|"[^¥¥¥¥¥x80-}
. q{¥xff¥n¥015"]*(?:¥¥¥¥[^¥x80-¥xff][^¥¥¥¥¥x80-¥xff¥n¥015"]*)*"))*@(?:[^(}
. q{¥040)<:>@,;:".¥¥¥¥¥[¥]¥000-¥037¥x80-¥xff]+(?![^(¥040)<:>@,;:".¥¥¥¥¥[¥]¥0}
. q{00-¥037¥x80-¥xff])|¥[(?:[^¥¥¥¥¥x80-¥xff¥n¥015¥[¥]]|¥¥¥¥[^¥x80-¥xff])*}
. q{¥])(?:¥.(?:[^(¥040)<:>@,;:".¥¥¥¥¥[¥]¥000-¥037¥x80-¥xff]+(?![^(¥040)<:>@,}
. q{;:".¥¥¥¥¥[¥]¥000-¥037¥x80-¥xff])|¥[(?:[^¥¥¥¥¥x80-¥xff¥n¥015¥[¥]]|¥¥¥¥[}
. q{^¥x80-¥xff])*¥]))*};
my $i = 0;
while($text =~ /($email_regex)/o && $i++ < 50) {
push(@emails, $1);
$text =~ s/$1/XXXXXXXXXX/g;
}
return @emails;
}
sub emailToLink {
my $text = shift;
my @emails = &getEmails($text);
foreach my $email (@emails) {
$text =~ s/$email/<a href=mailto:$email>$email<¥/>/g;
}
return $text;
}
1;
なし
#!/usr/bin/perl
sub getEmails {
my $text = shift;
my @emails;
my $email_regex =
q{(?:[^(¥040)<:>@,;:".¥¥¥¥¥[¥]¥000-¥037¥x80-¥xff]+(?![^(¥040)<:>@,;:".¥¥¥¥}
. q{¥[¥]¥000-¥037¥x80-¥xff])|"[^¥¥¥¥¥x80-¥xff¥n¥015"]*(?:¥¥¥¥[^¥x80-¥xff][}
. q{^¥¥¥¥¥x80-¥xff¥n¥015"]*)*")(?:¥.(?:[^(¥040)<:>@,;:".¥¥¥¥¥[¥]¥000-¥037¥x}
. q{80-¥xff]+(?![^(¥040)<:>@,;:".¥¥¥¥¥[¥]¥000-¥037¥x80-¥xff])|"[^¥¥¥¥¥x80-}
. q{¥xff¥n¥015"]*(?:¥¥¥¥[^¥x80-¥xff][^¥¥¥¥¥x80-¥xff¥n¥015"]*)*"))*@(?:[^(}
. q{¥040)<:>@,;:".¥¥¥¥¥[¥]¥000-¥037¥x80-¥xff]+(?![^(¥040)<:>@,;:".¥¥¥¥¥[¥]¥0}
. q{00-¥037¥x80-¥xff])|¥[(?:[^¥¥¥¥¥x80-¥xff¥n¥015¥[¥]]|¥¥¥¥[^¥x80-¥xff])*}
. q{¥])(?:¥.(?:[^(¥040)<:>@,;:".¥¥¥¥¥[¥]¥000-¥037¥x80-¥xff]+(?![^(¥040)<:>@,}
. q{;:".¥¥¥¥¥[¥]¥000-¥037¥x80-¥xff])|¥[(?:[^¥¥¥¥¥x80-¥xff¥n¥015¥[¥]]|¥¥¥¥[}
. q{^¥x80-¥xff])*¥]))*};
my $i = 0;
while($text =~ /($email_regex)/o && $i++ < 50) {
push(@emails, $1);
$text =~ s/$1/XXXXXXXXXX/g;
}
return @emails;
}
sub emailToLink {
my $text = shift;
my @emails = &getEmails($text);
foreach my $email (@emails) {
$text =~ s/$email/<a href=mailto:$email>$email<¥/>/g;
}
return $text;
}
1;