Slide 1

Slide 1 text

Çäåñü âîäÿòñÿ äðàêîíû: perltrap.com Åëåíà Áîëüøàêîâà 2014-06-14

Slide 2

Slide 2 text

Ñêîëüêî íîã ó 7 ìóðàâüåâ? use strict; use warnings; # êîëè÷åñòâî ëàï ó îäíîãî ìóðàâüÿ sub AN_ANT_LEGS { 6 }; print "1 ant has ".AN_ANT_LEGS." legs\n"; print "7 ants have ".(AN_ANT_LEGS * 7)." legs\n"; http://perltrap.com/ru/skolko-nog-u-7-muravev

Slide 3

Slide 3 text

Èñòèíàëîæü, íîëüíå íîëü use feature qw/say/; sub check_value { my $var = @_; say defined $var ? "defined" : "undefined"; say $var ? "true" : "false"; say $var == 0 ? "zero" : "not a zero"; return; } http://perltrap.com/ru/dened-true-nonzero

Slide 4

Slide 4 text

Óëó÷øåííûé push # ðàáîòàåò êàê push, íî ïåðâûé ïàðàìåòð -- íå ìàññèâ, # à ññûëêà íà ìàññèâ sub rpush { my $arr = shift; splice(@$arr, @$arr, 0, @_); return scalar @$arr; } http://perltrap.com/ru/uluchshennyj-push

Slide 5

Slide 5 text

Ïðîâåðü ñåáÿ, ïîðåøàé çàäà÷êè! http://perltrap.com twitter: @perltrapcom #perl #çàäà÷è #ãîëîâîëîìêè