开发者

Why does this Perl function return a value?

   $hi = do_this('asdf');

   sub do_this
   {
       $blob{'f'} = {
          'k' => 'j'
      };
   }

   print $hi->{'k'};
   # prints j

since do_开发者_如何学Gothis doesn't return anything, how does it still print j?


http://perldoc.perl.org/functions/return.html

In the absence of an explicit return, a subroutine, eval, or do FILE automatically returns the value of the last expression evaluated


All Perl 5 subroutines return the last value of the last statement executed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜