develooper Front page | perl.perl5.porters | Postings from November 2013

[perl #120610] return statement is required

Thread Previous | Thread Next
From:
Daneel S . Yaitskov
Date:
November 22, 2013 13:44
Subject:
[perl #120610] return statement is required
Message ID:
rt-4.0.18-28637-1385105971-347.120610-75-0@perl.org
# New Ticket Created by  Daneel S. Yaitskov 
# Please include the string:  [perl #120610]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=120610 >


I wrote recursive function that builds a tree of hashes.

If skip return keyword before result value of tree node (not a leaf)
final result is just a leaf. All non leaf nodes are lost.

I guess perl treats the last value of the function not hash 
rather value returned by function call inside the hash.

Expected result:

e$VAR1 = {
          '1' => {
                   '2' => {
                            '3' => {
                                     'end' => 'end'
                                   }
                          }
                 }
        };

Real one:
$VAR1 = 1;
$VAR2 = 2;
$VAR3 = 3;
$VAR4 = {
          'end' => 'end'
        };



This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi
Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About