Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: who can help me for a very interesting perl program

by choroba (Archbishop)
on May 03, 2016 at 07:53 UTC ( #1162073=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1162073]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2022-08-17 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?