日常業務にperlを使おう

download 日常業務にperlを使おう

If you can't read please download the document

description

YAPC::Asia Tokyo 2011 のLTで発表したスライドです。

Transcript of 日常業務にperlを使おう

  • 1. perl Let's use perl in your daily work 2011-10-14 @YAPC::Asia Tokyo 2011turugina

2. H.N.: turugina Web Site : http://floralcompany.jp/ Twitter: @turugina CPAN: http://search.cpan.org/~turugina/ : Perl, C++ : Ruby, Java 3.

  • perl

4. 5. 1 6. MISSION: 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. MISSION: 21. ... 22. perl 23. but 24. Web 25. 26. 27. 28. lwp-request(GET)

  • lwp-request-P "http://ikisaki/change.php?empno=999&today_status=17&nextday_status=2&nextday_hour=11&nextday_min=00"

29. lwp-request(GET)

  • lwp-request-P"http://ikisaki/change.php? empno=999 & today_status=17 & nextday_status=2 & nextday_hour=11&nextday_min=00 "

30. -P-> no proxy (Intranet ) 31. empno=999-> 999 32. today_status=17-> 33. nextday_status=2-> 34. nextday_hour=11&nextday_min=00-> (11:00 a.m.) 35. lwp-request(GET)

  • lwp-request-P-d"http://ikisaki/change.php?empno=999&today_status=17&nextday_status=2&nextday_hour=11&nextday_min=00"

36. -d-> 37. POST 38. lwp-request(POST)

  • perl -e "print q{empno=999&today_status=17&nextday_status=2&nextday_hour=11&nextday_min=30}" |lwp-request -P -d-m POST -c application/x-www-form-urlencodedhttp://ikisaki/change.php

39. -m POST-> HTTP 40. -c application/x-www-form-urlencoded-> POSTcontent-type 41. one-liner

  • perl -MLWP::UserAgent -e LWP::UserAgent->new->post(qw{http://ikisaki/change.php empno 999 today_status 17 nextday_status 2 nextday_hour 11 nextday_min 00})

42. Basic 43. lwp-request

  • lwp-request -P -d-C turugina:hogehogehttp://ikisaki/(r y

44. -C turugina:hogehoge-> Basiccredencial 45. 46. use strict; use warnings; use LWP::UserAgent; use Config::Pit; my $cfg = pit_get("ikisaki" , require => { user => "your user id", pass => "your pass" }); my $ua =LWP::UserAgent->new; $ua->credentials( "ikisaki:80", "ikisaki", @$cfg{qw{user pass}} ); my %setting = ( empno => 999, today_status => 17, ... ); $ua->get( 'http://ikisaki/change.php', %setting ); # or $ua->post( 'http://ikisaki/change.php', %setting ); 47. form 48. WWW::Mechanize use WWW::Mechanize; use Config::Pit; my $cfg = pit_get("ikisaki" , require => { user => "your user id", pass => "your pass" }); my $ua = WWW::Mechanize->new; $ua->get("http://ikisaki/index.php"); $ua->submit_form(# form_id => "login", with_fields => $cfg ); $ua->submit_form(...); # 49. Flash( Silverlight( ActiveX(ry 50. (# 51. Win32::GuiTest use Win32::GuiTest qw/:ALL/; system(qq{cmd.exe /c "start explorer http://ikisaki/"}); my $w = WaitWindow('.*Windows Internet Explorer$', 30)or die "window not found!"; sleep 10;# Flash SendKeys("username{TAB}password~"); sleep 10;# SendKeys(.....) s.a. Perl (How to play Win32::GuiTest) TAKESAKO (Sat Oct 15 12:10) - 52.

53. Intenete.g. ) 54. 55. m(_ _)m