ドキドキPerl調査団 Part1

Ffd3f0ebea474176dfbe876216a793f9?s=47 AnaTofuZ
March 17, 2018

ドキドキPerl調査団 Part1

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

Ffd3f0ebea474176dfbe876216a793f9?s=128

AnaTofuZ

March 17, 2018
Tweet

Transcript

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

  2. None
  3. Θͨ͠ Ͱ͢

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

  5. ͋Δ೔

  6. ;ͱࢥ͏

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

  8. Α͘Θ͔ΔPerl • Perl1.0 —ɹ͋ͬͨΒ͍͠ • Perl2 - Տ໺ઌੜ͕ॳΊͯPerlͱग़ձͬͨ࣌ • Perl3

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

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

    ҧ͍͕෼͔ΒΜ • Perl4 ͋ͬͨΒ͍͠ • Perl5 զʑͷ஌ͬͯΔPerl ΋͸΍ ਆ࿩
  11. Perl 1.0 [ݕࡧ]

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

  13. None
  14. ࠓͰ΋ ಈ࡞

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

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

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

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

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

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

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

    • my,our,local…
  22. Perl1Ͱ͋Δ΋ͷ • ஔ׵ • ਖ਼نදݱ • Ϧετૢ࡞ (shift,unsift,pop,push) • @_

    • จࣈྻԋࢉࢠ • chop • each
  23. αϒϧʔνϯ΋͋Δͧ!! sub MAX { $max = pop(@_); while ($foo =

    pop(@_)) { $max = $foo if $max < $foo; } $max; } ... $bestday = do MAX($mon,$tue,$wed,$thu,$fri);
  24. 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"; }
  25. 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"; }
  26. ऑ఺ • Ͳ͏΋γϯϘϧςʔϒϧʹΞΫηεͰ͖ͳ͍ • αϒϧʔνϯʹ഑ྻΛ౉ͤͳ͍
 (ग़དྷͳ͘͸ͳ͍) • ίϯύΠϧΤϥʔͷϝοηʔδ͕ແͯ͘ݫ͠ ͍

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

  28. None
  29. None
  30. array_pop_shift.pl #!/usr/bin/env perl @names = ('Alice','Bob','Chris'); print pop @names .

    "\n"; print shift @names . "\n";
  31. 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"; }
  32. None
  33. ͦΕͬΆ͘ #!/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";
  34. !? apple apple apple

  35. ਖ਼ղྫ #!/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";
  36. ͜Ε΋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";
  37. None
  38. • .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"; }
  39. hash_func.plͰൃ֮ͨ͠໰୊఺ • delete͕ͳ͍ • undef͕ͳ͍ • exist΋ͳ͍ • ϋογϡͰ͸ͳ͋͘͘·Ͱศརͳ഑ྻ
 (ͨͩ͠഑ྻͷshiftͳͲ͸࢖͑ͳ͍)

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

  41. ͍ۤ͠……

  42. ݁࿦ • Perl5を使おう