Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 96151
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: BINGOS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.76_1
Fixed in: 0.76_1



Subject: [PATCH] modification of read-only variable errors
Hi, I found what appears to be a regression between 0.75 and 0.76. Code I have which works fine with 0.75, fails with: Modification of a read-only value attempted at /opt/perl-5.18.1/lib/site_perl/5.18.1/x86_64-linux/Net/DNS/Resolver/Base.pm line 223. The following patch fixes the issue for me. Many thanks. diff --git a/lib/Net/DNS/Resolver/Base.pm b/lib/Net/DNS/Resolver/Base.pm index 226df90..af0a4b6 100644 --- a/lib/Net/DNS/Resolver/Base.pm +++ b/lib/Net/DNS/Resolver/Base.pm @@ -219,6 +219,7 @@ sub read_config_file { open( FILE, $file ) or croak "Could not open $file: $!"; local $/ = "\n"; + local $_; while (<FILE>) { s/\s*[;#].*$//; # strip comment
Hi, I'm getting the same issue, although with a different consequences, e.g. code like this makes fills @domains array with undefined values instead of proper domains: my @domains = qw(example.com example.net); my @domains_with_nameservers { get_nameservers_for($_) } @domains; my $resolver; sub get_nameservers_for { $resolver ||= Net::DNS::Resolver->new; # get nameservers here # ... } As an alternative to BINGOS' method you could use more idiomatic Perl and write e.g.: while (my $line = <FILE>) { ... } instead of: while (<FILE>) { ... } Пнд Июн 02 15:09:12 2014, BINGOS писал: Show quoted text
> Hi, > > I found what appears to be a regression between 0.75 and 0.76. > > Code I have which works fine with 0.75, fails with: > > Modification of a read-only value attempted at /opt/perl- > 5.18.1/lib/site_perl/5.18.1/x86_64-linux/Net/DNS/Resolver/Base.pm line > 223. > > The following patch fixes the issue for me. > > Many thanks. > > diff --git a/lib/Net/DNS/Resolver/Base.pm > b/lib/Net/DNS/Resolver/Base.pm > index 226df90..af0a4b6 100644 > --- a/lib/Net/DNS/Resolver/Base.pm > +++ b/lib/Net/DNS/Resolver/Base.pm > @@ -219,6 +219,7 @@ sub read_config_file { > > open( FILE, $file ) or croak "Could not open $file: $!"; > local $/ = "\n"; > + local $_; > > while (<FILE>) { > s/\s*[;#].*$//; # strip > comment
Fixed in 0.77. Thanks