AnaTofuZ
March 17, 2018
960

# ドキドキPerl調査団 Part1

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

March 17, 2018

## Transcript

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

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

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

ҧ͍͕෼͔ΒΜ • Perl4 ͋ͬͨΒ͍͠ • Perl5 զʑͷ஌ͬͯΔPerl ΋͸΍ ਆ࿩

19. ### Perl1Ͱͳ͍΋ͷ • ൣғԋࢉࢠ • foreach (ग़དྷͳ͘͸ͳ͍) • ଞϞδϡʔϧ • use

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

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

pop(@_)) { \$max = \$foo if \$max < \$foo; } \$max; } ... \$bestday = do MAX(\$mon,\$tue,\$wed,\$thu,\$fri);
22. ### 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"; }
23. ### 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. ### array_pop_shift.pl #!/usr/bin/env perl @names = ('Alice','Bob','Chris'); print pop @names .

"\n"; print shift @names . "\n";
27. ### 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"; }
28. ### ͦΕͬΆ͘ #!/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";

30. ### ਖ਼ղྫ #!/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";
31. ### ͜Ε΋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";
32. ### • .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"; }