in reply to Re: Duplicate File Finder script reporting multiples
in thread Duplicate File Finder script reporting multiples

I wondered why 1) the use of %files in the check_file did not cause an uninitialized variable error and 2) why the variable declaration a few lines after did not wipe out the results of the find(). I ran the program in debug and tried to inspect the contents of %files after the function call, and I get "empty array". I inspect it again right after the variable declaration, and it is fully populated. I'm guessing this is some sort of symbol table magic - can someone explain?

Dum Spiro Spero
  • Comment on Re^2: Duplicate File Finder script reporting multiples

Replies are listed 'Best First'.
Re^3: Duplicate File Finder script reporting multiples
by choroba (Cardinal) on Mar 30, 2015 at 14:39 UTC
    Ad 1) The subroutine check_file is declared in the scope where %files is declared. If you dereference an undefined value that's not read only, it autovivifies.

    Ad 2) The declaration doesn't change the value. The assignment would - try changing it to

    my %files = ();
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ