Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^6: who can help me with a very interesting Perl program?

by Anonymous Monk
on May 04, 2016 at 07:55 UTC ( [id://1162163]=note: print w/replies, xml ) Need Help??


in reply to Re^5: who can help me with a very interesting Perl program?
in thread who can help me for a very interesting perl program

many thanks for Athanasius' great help!! I still want to ask question. maybe I am not good at Perl, so forgive me. According to your debug output, for the initial value for @queue and $next, I can understand them well. but after the first while loop as below:

(1) @queue: $VAR1 = [ [ 'test\\dir1', {} ], [ 'test\\file1', $VAR1->[0][1] ], [ 'test\\file2', $VAR1->[0][1] ] ]; -------------------------------------------------- (1) $next: $VAR1 = [ 'test\\dir1', {} ];
why $VAR1->[0][1] is pointing to {}? I don't understand it. $ref->{'test'} or $ref->{'dir1'} seems to be "undef" for ever because the last statement is just a single $hash in "while" loop that is returned to $ref->{'test'} or $ref->{'dir1'}. for the 3rd loop as below
(3) @queue: $VAR1 = [ [ 'test\\file1', { 'dir1' => { 'file3' => undef } } ], [ 'test\\file2', $VAR1->[0][1] ] ];
why 'dir1' had pointed to {'file3' => undef}. $hash had never been assigned one value within in "while" loop, so $ref->{$basename} should be empty for ever when $basename was a directory. Thanks again

Replies are listed 'Best First'.
Re^7: who can help me with a very interesting Perl program?
by Athanasius (Archbishop) on May 04, 2016 at 12:10 UTC

    I’d like to help, but I don’t know what I can add to what’s already been said.

    Maybe you need to read up on references? Start with perlreftut, then look at perldsc and perlref. The Monastery’s Tutorials section also has a sub-section on References. And if you have access to the Camel Book, have a look at Chapter 8. Then go back over the replies above by choroba and by me.

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-19 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found