Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Perl使いの国のRubyist

 Perl使いの国のRubyist

2018-05-12 RejectKaigi 2018

Takafumi ONAKA

May 12, 2018
Tweet

More Decks by Takafumi ONAKA

Other Decks in Technology

Transcript

  1. ࠷ۙͷ1FSMͱ࠷ۙͷ3VCZ w DQBOUT  IUUQTDQBOUTDQBOBVUIPSTPSH 2009 21070 2010 22227 2011

    21910 2012 22647 2013 25760 2014 27272 2015 22999 2016 19982 2017 16352 2018 6052 => 17096 ϖʔε
  2. ࠷ۙͷ1FSMͱ࠷ۙͷ3VCZ w SVCZHFNTPSH  IUUQTSVCZHFNTPSHQBHFTEBUB Version.group("TO_CHAR(created_at, 'YYYY')").count.sort # => [["2009",

    39336], ["2010", 59267], ["2011", 82608], ["2012", 104318], ["2013", 125526], ["2014", 155369], ["2015", 132626], ["2016", 121681], ["2017", 108671], ["2018", 36498]] => 105485 ϖʔε
  3. 1FSMʹ׳ΕΔͨΊʹ΍ͬͨ͜ͱ w DBSUPOJOTUBMM࣌ʹยͬ୺͔ΒHIRHFU͢Δ ϚϯΛॻ͍ͨ w HFNTSDͷQFSM൛ ޙʹDQBOHIRΛݟ ͚ͭΔʜʜ  w

    ϝλϑΝΠϧʹSFQPTJUPSZ͕ࡌͬͯͳ͍ $1"/Ϟδϡʔϧ͕݁ߏ͋Δ w Ұ୴ϦετΛ͚࣋ͬͨͲɺ13ͯ͠ճΒͳ ͍ͱͳ͊
  4. 1FSMʹ׳ΕΔͨΊʹ΍ͬͨ͜ͱ w ͋ͱ͸࣮຿Ͱ&OVNFSBCMFͷϝιου܈Λ࢖͍·͘Δͷͱɺςετ Λॻ͘ͷͱ w -JTU6UJM -JTU.PSF6UJMT -JTU6UJMT#Z w 5FTU

    5FTU888.FDIBOJ[F14(* .PEVMF4QZ w ฏߦͯ͠ϝλϓϩάϥϛϯάͷษڧ΋ߦͬͨ w ࢖͍ͬͯΔπʔϧͷ࣮૷ํ๏͕ਪଌͰ͖ΔΑ͏ʹͳΔ
  5. @͕͋Δ w ҉໧తͳϒϩοΫม਺ w ϓϩμΫτίʔυͰ΋ϒϩοΫม਺͕൒෼͙Β͍ෆཁʹ my $array = ["a", "b",

    "c"]; for (@$array) { print $_ . "\n"; } my $array2 = [map { $_ . "foo"; } @$array];
  6. ͕͋Δ w Α͘΍ΔccͷϝϞԽ w GBMTZͳ஋ͩͱࠔΔ def foo @foo ||= heavy_method

    end # heavy_method ͕ boolean Λฦ͢ͱ͖͸ʁ def foo return @foo if defined?(@foo) @foo = heavy_method end
  7. είʔϓΛ೚ҙʹ࡞ΕΔ w ϨΩγΧϧείʔϓͱϦϑΝϨϯεΧ΢ϯτࣜ($ sub hoge { my $foo = 'foo';

    my $bar = 'bar'; { my $foo = 'baz'; print $foo . $bar . "\n"; # => 'bazbar' } print $foo . $bar . "\n"; # => 'foobar' }
  8. είʔϓΛ೚ҙʹ࡞ΕΔ w (VBSE͕࢖͑Δ sub hoge { { # ͜ͷϒϩοΫͷதͰ͚ͩ memcached

    ্ཱ͕͕ͪΔ my $guard = Proc::Guard->new(command => ["memcached", "-p", "11211"]); # do something ... } # ͜͜Ͱ͸ memcached ͕ఀࢭࡁΈ }
  9. είʔϓΛ೚ҙʹ࡞ΕΔ w ֤ݴޠͰΈͳ͞Μؤுͬͯ·͢ w 3VCZͰείʔϓΛ͸ͣΕͨͱ͖ʹࣗಈͰԿ͔Λ͢ΔcUFDI൙ཞݪ w IUUQTMPXSFBMOFU w 5SBDF1PJOUͷ࿩ɻ3VCZ,BJHJຊฤͷUBHPNPSJTKPLFSͷൃදΛָ͓͠Έʹ w

    1)1Ͱ΋1FSMͰ͍͏ͱ͜Ζͷ(VBSEΛ͢Δ΍ͰʂʂV[VMMB͕ϒϩά w IUUQV[VMMBIBUFCMPKQFOUSZ w 1FSMͷ4DPQF(VBSEΛ$PNNPO-JTQͰ࣮૷͢Δͧʂʂʂ-BNCEBΧΫςϧ w IUUQTXJOEZNFMUIBUFOBCMPHDPNFOUSZ
  10. μΠφϛοΫείʔϓ͕͋Δ our $foo = 'foo'; sub print_foo { print $foo

    . "\n"; } print_foo; # foo { local $foo = 'bar'; print_foo; # bar } print_foo; # foo
  11. ࣮ߦ࣌ܕνΣοΫ͕ී௨ use Smart::Args::TypeTiny qw(args); sub create { args my $id

    => 'Id', my $title => 'Str', my $description => 'Maybe[Str]', my $comment => { isa => 'Str', optional => 1 }, # do something... } # ࢖͏ͱ͖͸ hash Λ౉͢ create( id => 1, title => "title", description => undef, );
  12. ίϯςΫετ͕͋Δ my $a = localtime; my @b = localtime; use

    Data::Dumper; print Dumper $a; # $VAR1 = 'Fri May 4 16:14:45 2018'; print Dumper @b; # $VAR1 = 45; # $VAR2 = 14; # $VAR3 = 16; # $VAR4 = 4; # $VAR5 = 4; # $VAR6 = '118'; # $VAR7 = 5; # $VAR8 = 123;
  13. TUSJDUNPEF͕͋Δ w NZΛ෇͚ͳ͍ม਺એݴͷېࢭͱ͔ w ৚݅ࣜͰ୅ೖ͔Ͳ͏͔͕ݟ෼͚΍͍͢ w JG NZGPPCBS  w

    ϝλϓϩېࢭͱ͔ w Ұ෦͚ͩڐ༰͢Δ͜ͱ͕Ͱ͖Δ w ͚ͦͩ͜είʔϓΛ෼͚ͯڐՄͰ͖Δͷ΋ศར
  14. TUSJDUNPEF͕͋Δ sub foo { print @_ . '\n'; } my

    $method_name = 'foo'; { # ಈతʹϝιου໊Λܾఆͯ͠ݺͼग़͢ͷΛ͚ͩ͜͜ڐՄ no strict 'refs'; &{$method_name}('bar'); }
  15. .PEVMF$PSF-JTU w ߦҎ্ͷڊେ)BTIͰ؅ཧ͞Ε͍ͯΔ 5.027009 => { delta_from => 5.027008, changed

    => { 'B::Op_private' => '5.027009', ... # 140ߦ 'warnings' => '1.41', }, removed => { 'Module::CoreList::TieHashDelta'=> 1, } }, 5.027010 => { delta_from => 5.027009, changed => { 'App::Prove' => '3.42', ... # 193ߦ
  16. CMFBE#SFBLT$1"/͕͋Δ w ޓ׵ੑͷҡ࣋Λڧ͘௥͍ٻΊ͍ͯΔײ w QFSMEPDQFSMQPMJDZ w %PXOUIJTSPBEMJFTNBEOFTT ޓ׵ੑΛࣦͬͨઌ͸ڰؾͰ͢  w

    XFWFIFMEPVSTFMWFTUPBGBSIJHIFSTUBOEBSEUIBO CBDLXBSEDPNQBUJCJMJUZCVHXBSEDPNQBUJCJMJUZ ޙํޓ׵ੑ ΑΓ΋͸Δ͔ʹߴ͍ʮޙํʮόάʯޓ׵ੑʯΛक͖ͬͯ·ͨ͠