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

Here be dragons: perltrap.com

Here be dragons: perltrap.com

http://perltrap.com -- небольшие задачи про Perl.

Заходите, решайте, присылайте ответы, подписывайтесь на rss и твиттер (@perltrapcom)

Elena Bolshakova

June 14, 2014
Tweet

More Decks by Elena Bolshakova

Other Decks in Programming

Transcript

  1. Ñêîëüêî íîã ó 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
  2. Èñòèíàëîæü, íîëüíå íîëü 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
  3. Óëó÷øåííûé push # ðàáîòàåò êàê push, íî ïåðâûé ïàðàìåòð --

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