Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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

by QuillMeantTen (Friar)
on May 03, 2016 at 06:35 UTC ( #1162067=note: print w/replies, xml ) Need Help??

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

Perl's map does exactly what it says on the tin: it maps one set of values to another (yeah sure, depends on what you mean by map). Hash gets returned at the last line of your else because you call it (you know that single line with only hash on it). unshift is used to to put a value at the beginning of an array. so the line you do not understand can be rephrased as (keeping in mind that we evaluate from right to left):

my @tmparray = map{[$_,$hash]} @new_paths; unshift @queue,@tmparray;
tmparray being an array of array refs each containing two values: one from new paths and an array_ref.
since afterward you keep going at queue until it's empty and you do not save anything in data, $data is undefined (beside the fact that it is an empty hash) and you only get the last $hash.

I invite anyone to point out any mistake, I do have some difficulties with composed statements such as this one too. I also hotly recommend perldoc brand of fishing.
Update:I dont think its hash that is returned, seems its data in any case because it gets called after the while as last statement

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2022-05-24 17:59 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (84 votes). Check out past polls.