SlideShare une entreprise Scribd logo
1  sur  56
Télécharger pour lire hors ligne
./
!""   repo
#     !"" Changes
#     !"" MANIFEST.SKIP
#     !"" Makefile.PL
#     !"" README
#     !"" lib
#     #   %"" SampleApp.pm
#     !"" t
#     #   %"" 00_compile.t
#     %"" xt
#          !"" 01_podspell.t
#          !"" 02_perlcritic.t
#          !"" 03_pod.t
#          %"" perlcriticrc
%""   sandbox
./lib
!"" SampleApp
#   !"" CLI
#   #   %"" Crawler.pm
#   !"" Role.pm     use Mouse::Role;


#   %"" Web
#       !"" API.pm            use Mouse;
                        with “SampleApp::Role”;


#       %"" Controller
#           %"" Root.pm        $c->model(“API”)->get_entries();


%"" SampleApp.pm
use   LWP::UserAgent;
use   Email::Sender::Simple qw(sendmail);
use   Email::MIME;
use   Try::Tiny;
use   YAML qw(LoadFile);
use   Path::Class qw( file );

my $file = $ARGV[0] || "config.yaml";
die "Can't open $file" unless ( -f file($file)->stringify );
my $config = LoadFile( file($file) );
my $ua = LWP::UserAgent->new( agent => 'Monita/0.01', timeout => 30 );

for my $url ( @{ $config->{url} } ) {
    my $res = $ua->get($url);
    send_report( $res ) unless $res->is_success;
}

sub send_report {
    my $res = shift;
    my $email = Email::MIME->create(
        header => [
             From    => $config->{from},
             To      => $config->{to},
             Subject => $res->request->uri . ' : ' . $res->code,
        ],
        attributes => { content_type => 'text/plain', },
        body        => $res->status_line,
    );
    try { sendmail($email) }
    catch { my $error = $_; warn $error->message };
}
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -

Contenu connexe

Tendances

Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
diego_k
 
PerlでWeb API入門
PerlでWeb API入門PerlでWeb API入門
PerlでWeb API入門
Yusuke Wada
 
20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
Tatsuhiko Miyagawa
 
Decoupling Objects With Standard Interfaces
Decoupling Objects With Standard InterfacesDecoupling Objects With Standard Interfaces
Decoupling Objects With Standard Interfaces
Thomas Weinert
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
Fabien Potencier
 

Tendances (20)

Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
 
PerlでWeb API入門
PerlでWeb API入門PerlでWeb API入門
PerlでWeb API入門
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
 
20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
 
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
 
Mojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tMojolicious: what works and what doesn't
Mojolicious: what works and what doesn't
 
16.mysql stored procedures in laravel
16.mysql stored procedures in laravel16.mysql stored procedures in laravel
16.mysql stored procedures in laravel
 
Getting out of Callback Hell in PHP
Getting out of Callback Hell in PHPGetting out of Callback Hell in PHP
Getting out of Callback Hell in PHP
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perl
 
Example code for the SADI BMI Calculator Web Service
Example code for the SADI BMI Calculator Web ServiceExample code for the SADI BMI Calculator Web Service
Example code for the SADI BMI Calculator Web Service
 
Sadi service
Sadi serviceSadi service
Sadi service
 
Laravel the right way
Laravel   the right wayLaravel   the right way
Laravel the right way
 
Decoupling Objects With Standard Interfaces
Decoupling Objects With Standard InterfacesDecoupling Objects With Standard Interfaces
Decoupling Objects With Standard Interfaces
 
TDC2015 Porto Alegre - Automate everything with Phing !
TDC2015 Porto Alegre - Automate everything with Phing !TDC2015 Porto Alegre - Automate everything with Phing !
TDC2015 Porto Alegre - Automate everything with Phing !
 
Undercover Pods / WP Functions
Undercover Pods / WP FunctionsUndercover Pods / WP Functions
Undercover Pods / WP Functions
 
Introduction to the Pods JSON API
Introduction to the Pods JSON APIIntroduction to the Pods JSON API
Introduction to the Pods JSON API
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
 

En vedette

理解したつもりになるGit入門
理解したつもりになるGit入門理解したつもりになるGit入門
理解したつもりになるGit入門
Yoshihiro Sasaki
 
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
Ryosuke IWANAGA
 
Google trends to_irc
Google trends to_ircGoogle trends to_irc
Google trends to_irc
rarere
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
goccy
 

En vedette (20)

Oppai-Detect 3
Oppai-Detect 3Oppai-Detect 3
Oppai-Detect 3
 
エロサイトを作る上での限りなくブラックに近すぎるグレー なバッドノウハウ
エロサイトを作る上での限りなくブラックに近すぎるグレー なバッドノウハウエロサイトを作る上での限りなくブラックに近すぎるグレー なバッドノウハウ
エロサイトを作る上での限りなくブラックに近すぎるグレー なバッドノウハウ
 
いかにしてエロ動画を検索するか GXEB #03
いかにしてエロ動画を検索するか GXEB #03いかにしてエロ動画を検索するか GXEB #03
いかにしてエロ動画を検索するか GXEB #03
 
YAPCレポートの舞台裏
YAPCレポートの舞台裏YAPCレポートの舞台裏
YAPCレポートの舞台裏
 
テーマ「最適化」
テーマ「最適化」テーマ「最適化」
テーマ「最適化」
 
Takao.mt 2013
Takao.mt 2013Takao.mt 2013
Takao.mt 2013
 
Asset Pipeline for Perl
Asset Pipeline for PerlAsset Pipeline for Perl
Asset Pipeline for Perl
 
テーマ「なんでもないようなこと」
テーマ「なんでもないようなこと」テーマ「なんでもないようなこと」
テーマ「なんでもないようなこと」
 
Currying in perl
Currying in perlCurrying in perl
Currying in perl
 
理解したつもりになるGit入門
理解したつもりになるGit入門理解したつもりになるGit入門
理解したつもりになるGit入門
 
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
 
Using Dancer
Using DancerUsing Dancer
Using Dancer
 
PHPカンファレンス北海道_20160416
PHPカンファレンス北海道_20160416PHPカンファレンス北海道_20160416
PHPカンファレンス北海道_20160416
 
Use Carton
Use CartonUse Carton
Use Carton
 
YAPC::Asia 2013 - CPAN Testers Reports の情報を上手に使う
YAPC::Asia 2013 - CPAN Testers Reports の情報を上手に使うYAPC::Asia 2013 - CPAN Testers Reports の情報を上手に使う
YAPC::Asia 2013 - CPAN Testers Reports の情報を上手に使う
 
Plack::Request with Encoding
Plack::Request with EncodingPlack::Request with Encoding
Plack::Request with Encoding
 
Games::* - Perlで 「ゲーム」しよう #hokkaidopm
Games::* - Perlで 「ゲーム」しよう #hokkaidopmGames::* - Perlで 「ゲーム」しよう #hokkaidopm
Games::* - Perlで 「ゲーム」しよう #hokkaidopm
 
YAPC::AsiaとHokkaido.pm
YAPC::AsiaとHokkaido.pmYAPC::AsiaとHokkaido.pm
YAPC::AsiaとHokkaido.pm
 
Google trends to_irc
Google trends to_ircGoogle trends to_irc
Google trends to_irc
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 

Similaire à エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -

Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
lestrrat
 
Curscatalyst
CurscatalystCurscatalyst
Curscatalyst
Kar Juan
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
Yehuda Katz
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Tatsuhiko Miyagawa
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
brian d foy
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
Yehuda Katz
 

Similaire à エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 - (20)

Perl Web Client
Perl Web ClientPerl Web Client
Perl Web Client
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Perl: Hate it for the Right Reasons
Perl: Hate it for the Right ReasonsPerl: Hate it for the Right Reasons
Perl: Hate it for the Right Reasons
 
Web::Machine - Simpl{e,y} HTTP
Web::Machine - Simpl{e,y} HTTPWeb::Machine - Simpl{e,y} HTTP
Web::Machine - Simpl{e,y} HTTP
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Curscatalyst
CurscatalystCurscatalyst
Curscatalyst
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Ruby gems
Ruby gemsRuby gems
Ruby gems
 
Perl web app 테스트전략
Perl web app 테스트전략Perl web app 테스트전략
Perl web app 테스트전략
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
 
ELK: a log management framework
ELK: a log management frameworkELK: a log management framework
ELK: a log management framework
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 

Plus de Yusuke Wada

僕らがWebサービスをつくる5つの理由
僕らがWebサービスをつくる5つの理由僕らがWebサービスをつくる5つの理由
僕らがWebサービスをつくる5つの理由
Yusuke Wada
 

Plus de Yusuke Wada (20)

僕がつくった 70個のうちの48個のWebサービス達
僕がつくった 70個のうちの48個のWebサービス達僕がつくった 70個のうちの48個のWebサービス達
僕がつくった 70個のうちの48個のWebサービス達
 
スッとGoを取り入れる
スッとGoを取り入れるスッとGoを取り入れる
スッとGoを取り入れる
 
東京脱出計画中
東京脱出計画中東京脱出計画中
東京脱出計画中
 
Extreme remote working
Extreme remote workingExtreme remote working
Extreme remote working
 
Podcastを支える技術、エンジニアのためのWebメディア、そしてCPAN
Podcastを支える技術、エンジニアのためのWebメディア、そしてCPANPodcastを支える技術、エンジニアのためのWebメディア、そしてCPAN
Podcastを支える技術、エンジニアのためのWebメディア、そしてCPAN
 
創造のプロセスを回せ!v0.01
創造のプロセスを回せ!v0.01創造のプロセスを回せ!v0.01
創造のプロセスを回せ!v0.01
 
It's not only about "REMOTE"
It's not only about "REMOTE"It's not only about "REMOTE"
It's not only about "REMOTE"
 
事故からはじまるスケールチャンス
事故からはじまるスケールチャンス事故からはじまるスケールチャンス
事故からはじまるスケールチャンス
 
Google BigQueryを使ってみた!
Google BigQueryを使ってみた!Google BigQueryを使ってみた!
Google BigQueryを使ってみた!
 
Webサービスのコンテンツパターン 或いはデータの活⽤
Webサービスのコンテンツパターン 或いはデータの活⽤Webサービスのコンテンツパターン 或いはデータの活⽤
Webサービスのコンテンツパターン 或いはデータの活⽤
 
とある Perl Monger の働き方
とある Perl Monger の働き方とある Perl Monger の働き方
とある Perl Monger の働き方
 
5 minutes - YAPC::Asia Tokyo 2014
5 minutes - YAPC::Asia Tokyo 20145 minutes - YAPC::Asia Tokyo 2014
5 minutes - YAPC::Asia Tokyo 2014
 
Podcastをカジュアルに 支える技術
Podcastをカジュアルに 支える技術Podcastをカジュアルに 支える技術
Podcastをカジュアルに 支える技術
 
The master plan of scaling a web application
The master plan ofscaling a web applicationThe master plan ofscaling a web application
The master plan of scaling a web application
 
そのWebサービスは本当に「あたりまえ」だったのか?
そのWebサービスは本当に「あたりまえ」だったのか?そのWebサービスは本当に「あたりまえ」だったのか?
そのWebサービスは本当に「あたりまえ」だったのか?
 
Mojoliciousでつくる! Webアプリ入門
Mojoliciousでつくる! Webアプリ入門Mojoliciousでつくる! Webアプリ入門
Mojoliciousでつくる! Webアプリ入門
 
10 things to learn from Bokete
10 things to learn from Bokete10 things to learn from Bokete
10 things to learn from Bokete
 
僕らの履歴書
僕らの履歴書僕らの履歴書
僕らの履歴書
 
僕らがWebサービスをつくる5つの理由
僕らがWebサービスをつくる5つの理由僕らがWebサービスをつくる5つの理由
僕らがWebサービスをつくる5つの理由
 
僕らがつくるための 「5W」について
僕らがつくるための 「5W」について僕らがつくるための 「5W」について
僕らがつくるための 「5W」について
 

Dernier

Dernier (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. ./ !"" repo #   !"" Changes #   !"" MANIFEST.SKIP #   !"" Makefile.PL #   !"" README #   !"" lib #   #   %"" SampleApp.pm #   !"" t #   #   %"" 00_compile.t #   %"" xt #   !"" 01_podspell.t #   !"" 02_perlcritic.t #   !"" 03_pod.t #   %"" perlcriticrc %"" sandbox
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39. ./lib !"" SampleApp #   !"" CLI #   #   %"" Crawler.pm #   !"" Role.pm use Mouse::Role; #   %"" Web #   !"" API.pm use Mouse; with “SampleApp::Role”; #   %"" Controller #   %"" Root.pm $c->model(“API”)->get_entries(); %"" SampleApp.pm
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48. use LWP::UserAgent; use Email::Sender::Simple qw(sendmail); use Email::MIME; use Try::Tiny; use YAML qw(LoadFile); use Path::Class qw( file ); my $file = $ARGV[0] || "config.yaml"; die "Can't open $file" unless ( -f file($file)->stringify ); my $config = LoadFile( file($file) ); my $ua = LWP::UserAgent->new( agent => 'Monita/0.01', timeout => 30 ); for my $url ( @{ $config->{url} } ) { my $res = $ua->get($url); send_report( $res ) unless $res->is_success; } sub send_report { my $res = shift; my $email = Email::MIME->create( header => [ From => $config->{from}, To => $config->{to}, Subject => $res->request->uri . ' : ' . $res->code, ], attributes => { content_type => 'text/plain', }, body => $res->status_line, ); try { sendmail($email) } catch { my $error = $_; warn $error->message }; }