I have written a program that searches files for strings. But it does a lot of looping. once the search is complete, it asks if you would like to search again. However, I've found that the array's and scalars still contain the information that was saved on the first search, so I get those results + my new ones. That's not what I want. I ended up fixing it by declaring them all = 0 at the beginning of the subroutine. For the arrays though, they now contain the value [0] so if my variable was called "@searches" I wrote
@tmp = pop(@searches);
and that would remove the 0 value from @searches. Works fine, but I feel awkward creating a new array called @tmp to get rid of that value. Is there any way to completely empty an array or scalar? nullify it?
@tmp = pop(@searches);
and that would remove the 0 value from @searches. Works fine, but I feel awkward creating a new array called @tmp to get rid of that value. Is there any way to completely empty an array or scalar? nullify it?