Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: who can help me for a very interesting perl program by QuillMeantTen
in thread who can help me for a very interesting perl program by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2022-06-26 05:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (83 votes). Check out past polls.

    Notices?