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. HTH, Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]