Skip Menu |

This queue is for tickets about the URI CPAN distribution.

Report information
The Basics
Id: 68179
Status: open
Priority: 0/
Queue: URI

Owner: Nobody in particular
Requestors: MARKLE [...]

Bug Information
Severity: (no value)
Broken in: 1.58
Fixed in: (no value)

Subject: weird URI/URI::Escape behavior with Readonly
Download (untitled) / with headers
text/plain 1.2k
This is weird. If I change this to assign the vars of the 'for' loop to a loop var instead of $_, it works as expected. However, I'm not passing $_ to the UserAgent at all, the call to get() uses a new string. Why would something in URI try to operate on and modify $_ at the scope of the caller's loop? This is perl 5.8.8 in CentOS. Thanks have a nice day. --mark-- #!/usr/bin/perl use strict; use warnings FATAL => 'all'; use English '-no_match_vars'; use YAML; use Readonly; use LWP; Readonly my @lame => qw( ); my $ua = LWP::UserAgent->new(); for (@lame) { my $response = $ua->get("http://$_"); print Dump($response->headers); } __END__ hedges@foo:~$ ~/ Modification of a read-only value attempted at /usr/lib/perl5/site_perl/5.8.8/URI/ line 6 Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/URI/ line 3. Compilation failed in require at (eval 15) line 3. Callback called exit. END failed--call queue aborted at /home/digicine/hedges/ line 6. In a more complex script it turned up as: Modification of a read-only value attempted at /usr/lib/perl5/site_perl/5.8.8/HTTP/ line 4 Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/LWP/ line 746. Callback called exit.
Download (untitled) / with headers
text/plain 761b
This is certainly weird. With perl-5.14 this problem no longer exists. The perl5140delta says: local($_) strips all magic from $_ local() on scalar variables gives them a new value but keeps all their magic intact. This has proven problematic for the default scalar variable $_, where perlsub recommends that any subroutine that assigns to $_ should first localize it. This would throw an exception if $_ is aliased to a read‐only variable, and could in general have various unintentional side‐effects. Therefore, as an exception to the general rule, local($_) will not only assign a new value to $_, but also remove all existing magic from it as well. which might be this issue.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to