Looks like the local and the quotes on the for line do the trick.

Thanks.

On Tue, 13 Dec 2011, Mark Hindley wrote:

On Mon, Dec 12, 2011 at 09:21:07PM +0000, Mark Hindley wrote:
Thanks for this, but I am afraid I don't quite understand what is going
on.

I can see the uninitialized value warning, but I can't see how it is
arising. :(

I have woken up with my brain working this morning! I had forgotten that
$_ is not localized automatically in while loops. This should fix the
uninitialized value warning.

Mark
commit 8319befeebbb72bfdc7f2c53ac4bad9e141d0407
Author: Mark Hindley <m...@hindley.org.uk>
Date:   Tue Dec 13 09:16:13 2011 +0000

   Localize $_ before while (<$fh>) loop.

diff --git a/apt-cacher b/apt-cacher
index dccb22e..d0989c7 100755
--- a/apt-cacher
+++ b/apt-cacher
@@ -1990,6 +1990,7 @@ sub get_inetd_port {
            open(my $fh, '<', $_) || do {
                info_message("Warning: Cannot open $_, $!"); next;
            };
+           local $_;
          LINE:
            while (<$fh>) {
                next LINE if /^(?:#|$)/; # Weed comments and empty lines


--
Jon Daley
http://jon.limedaley.com
~~
Anything dropped in the bathroom falls in the toilet.
-- Flucard's Corollary



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to