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

ドキドキPerl調査団 Part1

AnaTofuZ
March 17, 2018

ドキドキPerl調査団 Part1

Okinawa.pm #6の発表資料です

AnaTofuZ

March 17, 2018
Tweet

More Decks by AnaTofuZ

Other Decks in Technology

Transcript

  1. υΩυΩPerlௐࠪஂ
    Part1
    @AnaTofuZ
    Okinawa.pm #6

    View full-size slide

  2. • Ξφάϥ(@AnaTofuZ)
    • ླྀେ@ฒྻ৴པݚ(u͞Μͷޙഐ)
    • Perl͕޷͖ɹʢόΠτઌ͸Ruby)
    • झຯ͸ΫιϦϓ
    ΞφάϥͰ͢

    View full-size slide

  3. Perl1.0͸
    ࣮ࡏ
    ͨ͠ͷ͔

    View full-size slide

  4. Α͘Θ͔ΔPerl
    • Perl1.0 —ɹ͋ͬͨΒ͍͠
    • Perl2 - Տ໺ઌੜ͕ॳΊͯPerlͱग़ձͬͨ࣌
    • Perl3 ҧ͍͕෼͔ΒΜ
    • Perl4 Տ໺ઌੜ͕ຊΛग़ͨ͠
    • Perl5 զʑͷ஌ͬͯΔPerl

    View full-size slide

  5. Α͘Θ͔ΔPerl
    • Perl1.0 —ɹ͋ͬͨΒ͍͠
    • Perl2 - Տ໺ઌੜ͕ॳΊͯPerlͱग़ձͬͨ࣌
    • Perl3 ҧ͍͕෼͔ΒΜ
    • Perl4 Տ໺ઌੜ͕ຊΛग़ͨ͠
    • Perl5 զʑͷ஌ͬͯΔPerl
    Perl1

    View full-size slide

  6. Α͘Θ͔ΔPerl
    • Perl1.0 —ɹ͋ͬͨΒ͍͠
    • Perl2 - Տ໺ઌੜ͕ॳΊͯPerlͱग़ձͬͨ࣌
    • Perl3 ҧ͍͕෼͔ΒΜ
    • Perl4 ͋ͬͨΒ͍͠
    • Perl5 զʑͷ஌ͬͯΔPerl
    ΋͸΍
    ਆ࿩

    View full-size slide

  7. Perl 1.0 [ݕࡧ]

    View full-size slide

  8. https://bitbucket.org/chastai/perl-1.0

    View full-size slide

  9. ࠓͰ΋
    ಈ࡞

    View full-size slide

  10. Perl5ͷσʔλܕ
    • εΧϥʔ
    • ഑ྻ
    • ϋογϡ
    • ϦϑΝϨϯε

    View full-size slide

  11. Perl1ͷσʔλܕ
    • εΧϥʔ
    • ഑ྻ
    • ϋογϡ
    • ϦϑΝϨϯε

    View full-size slide

  12. Perl1ͷσʔλܕ
    • εΧϥʔ
    • ഑ྻ
    • ϋογϡ
    • ϦϑΝϨϯε

    View full-size slide

  13. Perl1ͷσʔλܕ
    • εΧϥʔ
    • ഑ྻ + ࿈૝഑ྻ

    View full-size slide

  14. Perl1ͷσʔλܕ
    • εΧϥʔ
    • ഑ྻ + ࿈૝഑ྻ

    View full-size slide

  15. Perl1ͷσʔλܕ
    • String
    • String഑ྻ + ࿈૝഑ྻ

    View full-size slide

  16. Perl1Ͱͳ͍΋ͷ
    • ൣғԋࢉࢠ
    • foreach (ग़དྷͳ͘͸ͳ͍)
    • ଞϞδϡʔϧ
    • use
    • my,our,local…

    View full-size slide

  17. Perl1Ͱ͋Δ΋ͷ
    • ஔ׵
    • ਖ਼نදݱ
    • Ϧετૢ࡞ (shift,unsift,pop,push)
    • @_
    • จࣈྻԋࢉࢠ
    • chop
    • each

    View full-size slide

  18. αϒϧʔνϯ΋͋Δͧ!!
    sub MAX {
    $max = pop(@_);
    while ($foo = pop(@_)) {
    $max = $foo if $max < $foo;
    }
    $max;
    }
    ...
    $bestday = do MAX($mon,$tue,$wed,$thu,$fri);

    View full-size slide

  19. for loop΋ग़དྷΔͧ!!
    #!/usr/bin/env perl
    @array = (1,2,3,4,5,6,7,8,9,10);
    for ( $i = 0; $i < 10; $i++){
    print $array[$i] ."\n";
    }

    View full-size slide

  20. for loop (੒ޭ)
    #!/usr/bin/env perl
    @array = (1,2,3,4,5,6,7,8,9,10);
    for ( $i = 0; $i < 10; $i++){
    print $array["$i"] ."\n";
    }

    View full-size slide

  21. ऑ఺
    • Ͳ͏΋γϯϘϧςʔϒϧʹΞΫηεͰ͖ͳ͍
    • αϒϧʔνϯʹ഑ྻΛ౉ͤͳ͍

    (ग़དྷͳ͘͸ͳ͍)
    • ίϯύΠϧΤϥʔͷϝοηʔδ͕ແͯ͘ݫ͠
    ͍

    View full-size slide

  22. օ͞Μ
    ॻ͍ͯΈͨ͘ͳΓ·ͤΜ͔?

    View full-size slide

  23. array_pop_shift.pl
    #!/usr/bin/env perl
    @names = ('Alice','Bob','Chris');
    print pop @names . "\n";
    print shift @names . "\n";

    View full-size slide

  24. array_push_unshift.pl
    #!/usr/bin/env perl
    @names = ('Alice','Bob','Chris');
    push(@names,"Diana");
    unshift(@names,"Eve");
    for ($i = 0; $i < $#names+1; $i++){
    print $names["$i"]."\n";
    }

    View full-size slide

  25. ͦΕͬΆ͘
    #!/usr/bin/env perl
    $my_profile['name'] = 'AnaTofuZ';
    $my_profile['age'] = 21;
    $my_profile['food'] = 'apple';
    print $my_profile["name"] . "\n";
    print $my_profile["age"] . "\n";
    print $my_profile["food"] . "\n";

    View full-size slide

  26. !?
    apple
    apple
    apple

    View full-size slide

  27. ਖ਼ղྫ
    #!/usr/bin/env perl
    $my_profile{'name'} = 'AnaTofuZ';
    $my_profile{'age'} = 21;
    $my_profile{'food'} = 'apple';
    print $my_profile{"name"} . "\n";
    print $my_profile{"age"} . "\n";
    print $my_profile{"food"} . "\n";

    View full-size slide

  28. ͜Ε΋ok
    #!/usr/bin/env perl
    ($my_profile{'name'},$my_profile{'age'},
    $my_profile{'food'}) = ( 'AnaTofuZ',21,'apple');
    print $my_profile{"name"} . "\n";
    print $my_profile{"age"} . "\n";
    print $my_profile{"food"} . "\n";

    View full-size slide

  29. • .n
    #!/usr/bin/env perl
    $my_profile{'name'} = 'AnaTofuZ';
    $my_profile{'age'} = 21;
    $my_profile{'food'} = 'apple';
    @keys = keys(my_profile);
    for ($i = 0; $i < $#keys+1 ; $i++){
    print $keys[$i] . "\n";
    }
    $my_profile{'age'} = "";
    if ( $my_profile{'age'} == ""){
    print "Age is not exists (͋Δ͚Ͳ)\n";
    } else {
    print "Age is exitst";
    }

    View full-size slide

  30. hash_func.plͰൃ֮ͨ͠໰୊఺
    • delete͕ͳ͍
    • undef͕ͳ͍
    • exist΋ͳ͍
    • ϋογϡͰ͸ͳ͋͘͘·Ͱศརͳ഑ྻ

    (ͨͩ͠഑ྻͷshiftͳͲ͸࢖͑ͳ͍)

    View full-size slide

  31. Perl1.0ͷ࿈૝഑ྻ
    • ࿈૝഑ྻ͸͋͘·Ͱࢼݧతӡ༻ͩͬͨ
    • keys()ͳͲ͸؀ڥม਺ͷऔಘͰར༻Λ૝ఆ
    • ͪͳΈʹιʔτॱ͸ࣙॻॱ

    View full-size slide

  32. ͍ۤ͠……

    View full-size slide

  33. ݁࿦
    • Perl5を使おう

    View full-size slide