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

Perl Quiz

Perl Quiz

Gotanda.pm 2021/05/21

E4967f90a08dadff9cc185b863cd99a7?s=128

Shoichi Kaji

May 21, 2021
Tweet

More Decks by Shoichi Kaji

Other Decks in Programming

Transcript

  1. Perl Quiz😆 Shoichi Kaji

  2. Q1. ࣍ͷจষ͸ਖ਼͍͔͠? Time::Localύοέʔδʹ͓͍ͯ timelocalؔ਺Ͱ͸ͳ͘ timelocal_modernؔ਺Λ࢖͏ ͜ͱ͕ਪ঑͞Ε͍ͯΔɻ

  3. A1. ਖ਼͘͠ͳ͍

  4. • timelocal ͸جຊతʹ͸ localtime ͷ"ٯ"Λఏڙ͢Δؔ਺ɻ Y,m,d,H,M,SΛड͚औΓunixtimeΛฦ͢ɻ • ͕ɺ"DWIM"ͳڍಈΛ͢Δؔ܎্ɺ 2020೥Λڥʹ݁Ռ͕มΘΔՄೳੑ͕͋Δ😨 •

    ͜ΕΛղܾ͢΂͘ɺܾఆతͳ݁ՌΛฦ͢ timelocal_modern͕༻ҙ͞Εͨɻ • ͕ɺͦΕ΋গʑ͍·͍ͪͩͬͨͷͰɺݱࡏͰ͸ timelocal_posixΛ࢖͏͜ͱ͕ਪ঑͞Ε͍ͯΔɻ ͜Ε͸localtimeͷਅͷ"ٯ"Λఏڙ͢Δɻ
  5. Q2. ࣍ͷ ʹೖΔ΋ͷ͸Կ͔? ֎෦ίϚϯυͷඪ४ग़ྗΛ ಘΔؔ਺ͱͯ͠ qx//, ``, ͕͋Δɻ

  6. A2. readpipe

  7. • rjbs͞ΜͷϒϩάಡΜͰ͍ͯɺ readpipeͱ͍͏ؔ਺͕͋Δ͜ͱΛ࠷ۙ஌ͬͨɻ • ಉ͡ಇ͖Λ͢Δ૊ΈࠐΈؔ਺͕ 3ͭ΋͋Δඞཁ͸...

  8. Q3. PerlͰ͸ϋογϡϦϑΝϨϯεͱ ϒϩοΫʹಉ͡ه߸ {} Λ༻͍͍ͯΔɻ ͳΜΒ͔ͷཧ༝ͰϋογϡϦϑΝϨϯεΛ ໌͍ࣔͨ͠ͱ͖͸ +{} ͕ଟ༻͞ΕΔɻ Ͱ͸ٯʹϒϩοΫΛ໌͍ࣔͨ͠ͱ͖

    ͳΜͱॻ͘ͱΑ͍͔ʁ
  9. A3. {; }

  10. • metacpanΛோΊ͍ͯͨΒɺ App::UniϞδϡʔϧͰ࢖ΘΕ͍ͯͯ஌ͬͨɻ • ࣮ࡍͷͱ͜Ζɺ+{}, {; } ΋ຊ౰ʹඞཁͳ৔ॴ͸গ ͳ͍ͱࢥ͏😇

  11. Q4. Perl v5.16Ҏ্ʹ͓͍ͯ ࣮ߦϢʔβͷhomeσΟϨΫτϦ Λऔಘ͢Δ؆ศͳํ๏͸ʁ

  12. A4. my $home = (<~>)[0];

  13. • ΫϩεϓϥοτϑΥʔϜΛҙ্ࣝͨ͠Ͱ HomeσΟϨΫτϦΛऔಘ͢Δͷ͸݁ߏେมɻ • ͪΌΜͱ΍ΔͳΒFile::HomeDirϞδϡʔϧΛ࢖͏ͷ͕ ΑΖ͍͠ɻ • "͋Δఔ౓"Ͱे෼ͳΒɺάϩϒ(glob,<>)Ͱ "~" Λ

    ղܾͤͯ͞औಘ͢Δͷ͕ϥΫɻ • ͳ͓ɺPerl5.16ະຬ΋ҙ͍ࣝͨ͠ͳΒ File::HomeDir::TinyΛ࢖͏ͱΑΖ͍͠ɻ
  14. Q5. Perl͸͋ΔόʔδϣϯΑΓ @INCͷॱ൪͕มΘ͍ͬͯΔɻ มΘͬͨͷ͸࣍ͷ͏ͪͲΕ͔? (A) v5.10͔Β (B) v5.12͔Β (C) v5.14͔Β

  15. A5. (B) v5.12͔Β

  16. • @INC͸Ϟδϡʔϧαʔνύε͕ೖ͍ͬͯΔม਺ɻ • @INC͸جຊతʹ͸ * 1൪໨: CPANϞδϡʔϧೖΔsitelib * 2൪໨: coreϞδϡʔϧ͕ೖΔcorelib

    ʹΑͬͯߏ੒͞ΕΔɻ • ͕ɺ5.10Ҏલ͸corelib, sitelibͷॱʹͳ͍ͬͯͨɻ • ͦͷؔ܎্ɺ5.10ҎલͰdual lifeϞδϡʔϧΛΠϯετʔϧ͢Δ ͱɺcorelibʹ্ॻ͖͞ΕΔɻ • CartonͷޙܧCarmel͕v5.12Λཁٻ͍ͯ͠Δͷ͸͜Ε͕ཁҼɻ
  17. Q6. ҎԼͷίʔυΛWindowsͰ࣮ߦ͢Δͱ ʮHello, World!ʯ ͱදࣔ͞ΕΔɺ͞Εͳ͍?

  18. A6. දࣔ͞Εͳ͍

  19. • Windowsʹ͓͍ͯ͸ ͨͱ͑ system LIST ܗࣜͰ͋ͬͯ΋ ಛघจࣈΛΫΦʔτ͠ͳ͍ͱ͍͚ͳ͍Մೳੑ͕͋ Δɻ • ઌͷྫͩͱಛʹʮ"ʯ͕໰୊ͱͳͬͯ

    ʮHello World!ʯͱදࣔ͞Εͳ͍ɻ • Windows༻ͷΫΦʔτʹ͸ɺWin32::ShellQuote ϞδϡʔϧΛ࢖͏ͱΑ͍ɻ
  20. ͓ΘΓ