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