{"id":168559,"date":"2013-02-06T20:33:03","date_gmt":"2013-02-06T16:33:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=168559"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=168559","title":{"rendered":"<span class=\"post_title\">\u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0442\u0441\u0442\u0440\u0435\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u043d\u043e\u0433\u0443 \u0432 Perl<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"perl\">use strict; use warnings;  sub mysub($$) {     my ($a, $b) = @_;     print &quot;$a\\n&quot;;     print &quot;$b\\n&quot;; } my $x = undef; mysub($x && $x-&gt;[0] =~ \/abc\/, $x = []); <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u0435\u0442 \u043b\u0438 mysub \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0447\u0442\u043e, \u0447\u0442\u043e \u0432 boolean \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0439?<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0435\u0442, \u0432\u0435\u0434\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e $x \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432, \u0430 \u0435\u0433\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0443 &#8216;abc&#8217;<\/p>\n<p>  \u041d\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442  <\/p>\n<pre><code class=\"dos\">$perl poc.pl ARRAY(0xdb6d48) ARRAY(0xdb6d48) <\/code><\/pre>\n<p>  \u0412 \u0447\u0451\u043c \u0436\u0435 \u0434\u0435\u043b\u043e?<\/p>\n<ol>\n<li>\u0432 Perl (\u043a\u0430\u043a \u0438 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445) <b>X<\/b> &#038;&#038; <b>Y<\/b>, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 <b>X<\/b> \u2014 false, \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0438\u0442 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e false (\u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f <b>Y<\/b>), \u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0438\u0442 \u0441\u0430\u043c <b>X<\/b> (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c false)  <\/li>\n<li>\u0412\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 Perl \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u0430 \u043d\u0435 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e.<\/li>\n<\/ol>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442  <\/p>\n<pre><code class=\"perl\">$x && $x-&gt;[0] =~ \/abc\/ <\/code><\/pre>\n<p>  $x \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f undef \u0442.\u0435. false, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u0430\u043c $x,<br \/>  \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, $x \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 [] (\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432), \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043a\u043e\u0434 mysub, \u043e\u0431\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430<br \/>  \u0441\u043e\u0434\u0435\u0436\u0440\u0430\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 $x (\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c)<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b\u043c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u0442\u043e \u043c\u043e\u0433\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0447\u0442\u043e \u0431\u044b\u0433 \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435 unit \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code class=\"perl\">ok( ($errors && ($errors-&gt;[0] =~ \/My Exception\/i)), &quot;should catch exception $errors-&gt;[0]&quot; ); <\/code><\/pre>\n<p>  (\u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0438\u0447\u0430 \u043f\u0435\u0440\u043b\u0430 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Autovivification\">Autovivification<\/a> \u2014 \u0435\u0441\u043b\u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a $errors-&gt;[0] \u0442\u043e $error-&gt;[0] \u0441\u043e\u0437\u0434\u0430\u0441\u0442\u0441\u044f,<br \/>  \u0435\u0441\u043b\u0438 $error \u0431\u044b\u043b \u0434\u043e \u044d\u0442\u043e\u0433\u043e undef)    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/168559\/\"> http:\/\/habrahabr.ru\/post\/168559\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"perl\">use strict; use warnings;  sub mysub($$) {     my ($a, $b) = @_;     print &quot;$a\\n&quot;;     print &quot;$b\\n&quot;; } my $x = undef; mysub($x &#038;& $x-&gt;[0] =~ \/abc\/, $x = []); <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u0435\u0442 \u043b\u0438 mysub \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0447\u0442\u043e, \u0447\u0442\u043e \u0432 boolean \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0439?  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-168559","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/168559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=168559"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/168559\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=168559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=168559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=168559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}