a Var's lifetime should be never preceed, or outlast, its usefulness Declare at the last possible moment; go out of scope at the earliest #### my $XMLval=''; { open X,'myfile'; my @X= grep //,; last unless @X; $X[0] =~ s/<\/?[^>]+>//g; # shoot the tag and end tag.. $XMLVal=$X[0]; } # here we have $XMLval ready to go , all cleaned up, # and @X is out of scope , # so no worries about it anymore or any other gobbltygook # in the braces