From: "Paul Kraus" <[EMAIL PROTECTED]> > That did correct the problem. I don't understand what local $_; did. > So a while loop will change $_ if it is inside a foreach loop since > both use $_?
Please do not top-post! local stores the actual value of a global variable, undefines it and restores the old value at the end of the enclosing block: $x = 5; print "$x\n"; { local $x; print "$x\n"; $x = 10; print "$x\n"; } print "$x\n"; The problem was that you had foreach (@list) { ... while (<FILE>) { ... } ... } the foreach changes $_ to an alias to each element of the list iteratively, if you change $_ within the foreach loop you are changing the actual element of the @list. And since the while(<FILE>) reads the lines into $_ it overwritten the @list's elements. Just like foreach (@list) { ... $_ = 'some data'; ... } would overwrite them. Now the local makes sure that the value of $_ get's reset back at the end of the block, which in your code meant at the end of the point() subroutine. The same way foreach (@list) { ... { local $_; $_ = 'some data'; ... } ... } would. ---- Sorry about the top posting. I have always posted that way and no one has ever said a word. At any rate. So some functions such as foreach localize on there own. So nested foreach's will preserve $_. I think I got it now. Thanks!! Paul -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]