#!/usr/bin/perl -w
use Time::Local;
$year = 1980;
$mon = 8;
$day = 24;
my $birthday = timelocal(0, 0, 0, $day, $mon - 1, $year);
$age = int((time - $birthday) / 365.2425 / 24 / 60 / 60);
print $age;
1;
#!/usr/bin/perl -w
use Time::Local;
$year = 1980;
$mon = 8;
$day = 24;
my $birthday = timelocal(0, 0, 0, $day, $mon - 1, $year);
$age = int((time - $birthday) / 365.2425 / 24 / 60 / 60);
print $age;
1;
use HTTP::Date;
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Date;
# 初期化
my $html;
my $timezone = 'JST';
my $url = 'https://www.yoursite.com/index.rdf';
my $rss = new XML::RSS;
my $proxy = new LWP::UserAgent; # UseAgent の作成
my $req = new HTTP::Request(GET=>$url);
my $res = $proxy->request($req); # $url にアクセスする
my $xml = $res->content; # コンテンツ (この場合は RSS/XML) を取得
# RSS を解析
eval {
$rss->parse($xml);
};
if($@) {
# $rss->parse が失敗したとき
}
# @{$rss->{items}} に、RSS のすべてのエントリー (item) が入る
foreach my $item ( @{$rss->{items}} ) {
my $date = HTTP::Date::str2time($item->{dc}->{date}, $timezone);
$html .= qq|<a href=$item->{link}>$item->{title}</a><br>\n|; # タイトルをリンクつきで出力
$html .= qq|$description<br>| if $item->{description}; # 概要 (description) を出力
$html .= qq|[<a href=$item->{link}>続きを読む</a>]<hr size=1>\n|;
}
print $html;
1;
use HTTP::Date;
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Date;
# 初期化
my $html;
my $timezone = 'JST';
my $url = 'https://www.yoursite.com/index.rdf';
my $rss = new XML::RSS;
my $proxy = new LWP::UserAgent; # UseAgent の作成
my $req = new HTTP::Request(GET=>$url);
my $res = $proxy->request($req); # $url にアクセスする
my $xml = $res->content; # コンテンツ (この場合は RSS/XML) を取得
# RSS を解析
eval {
$rss->parse($xml);
};
if($@) {
# $rss->parse が失敗したとき
}
# @{$rss->{items}} に、RSS のすべてのエントリー (item) が入る
foreach my $item ( @{$rss->{items}} ) {
my $date = HTTP::Date::str2time($item->{dc}->{date}, $timezone);
$html .= qq|<a href=$item->{link}>$item->{title}</a><br>\n|; # タイトルをリンクつきで出力
$html .= qq|$description<br>| if $item->{description}; # 概要 (description) を出力
$html .= qq|[<a href=$item->{link}>続きを読む</a>]<hr size=1>\n|;
}
print $html;
1;
use Time::Local;
#!/usr/bin/perl
use Time::Local;
$time = timelocal($sec, $min, $hour, $day, $mon, $year);
$time = timegm ($sec, $min, $hour, $day, $mon, $year);
1;
use Time::Local;
#!/usr/bin/perl
use Time::Local;
$time = timelocal($sec, $min, $hour, $day, $mon, $year);
$time = timegm ($sec, $min, $hour, $day, $mon, $year);
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 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;