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