http://qs321.pair.com?node_id=1162073


in reply to who can help me for a very interesting perl program

The $hash is returned from do, i.e. it gets assigned to $ref->{$basename}. It goes to the queue, too, from where it gets shifted and extracted to $ref in a future iteration.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: who can help me for a very interesting perl program
by Anonymous Monk on May 03, 2016 at 08:26 UTC

    thanks choroba and QuillMeantTen. I am still confused. what is its value of "$hash" after performing "unshift @queue , map {$_, $hash} @new_paths;" And I always feel that the value of "$hash" is "undef" all alone, because "map" seems not to be able to assign a value to $hash.

    root@TestMachine:~/excerise_perl# perl data_for_path.pl $VAR1 = { 'test' => { 'file2' => undef, 'file1' => undef, 'dir1' => { 'file3' => undef } } };
    as the result from above, How does $$data->{'test'} point to its child directory.

      $hash is a hash reference. The referenced hash will get populated in a later iteration of the loop when it becomes $ref. The important thing is that the $hash returned from the do is the same empty hash as the one stored in the @queue by the map.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

        Hi choroba, for your words "The referenced hash will get populated in a later iteration of the loop when it becomes $ref ". can you explain/demonstrate it in detail:). I think the $hash is "undef" for ever.. Thanks a lot.