in reply to Re: LWP::Simple and Read-only Values
in thread LWP::Simple and Read-only Values

No, it is not the exact same code. The exact code includes this:
$asdf =~ /(asdf)/; $1 =~ s/asdf//;

In other words, I was trying to modify the special variable $1. Once I set $1 to something else, the code worked like a charm. Why can't I do substitutions on $1?

Replies are listed 'Best First'.
Re: Re: Re: LWP::Simple and Read-only Values
by chromatic (Archbishop) on Jul 13, 2003 at 03:08 UTC

    You can't modify $1 because it's a read only variable. It doesn't make sense to make it a writeable variable because it's only ever supposed to contain the first capture from the most recently successful match.

    That may not be the most convincing explanation, but that's the official reason. If you could modify the magic global captures, should or shouldn't it affect the matched string itself? That's pretty tricky and, pragmatically, it's a stone better left unturned.

Re: Re: Re: LWP::Simple and Read-only Values
by bobn (Chaplain) on Jul 13, 2003 at 03:01 UTC

    3rd edition of Camel flags these ($1, $2, etc.) clearly as readonly, as does perldoc perlvar

    --Bob Niederman, http://bob-n.com