in reply to Why does the array not reset each time I call the function?

How do you know that @data_file keeps values from previous use? @data_file is lexical to the CleanFiles() subroutine. Each time you call CleanFiles() you're going to get a fresh @data_file (that's how my works). Are you sure about what you're seeing?