in reply to LVALUE refs
This means for example that while this works:
$x = \substr("blah", 1, 2); $y = \substr("florp", 1, 3); print "$$x $$y\n";
this will not:
sub substrref { \substr($_[0], $_[1], $_[2]) } $x = substrref("blah", 1, 2); $y = substrref("florp", 1, 3); print "$$x $$y\n";
The work-around is to create a new lexical occurrance each time, by using eval STRING:
sub substrref { eval '\substr($_[0], $_[1], $_[2])' } $x = substrref("blah", 1, 2); $y = substrref("florp", 1, 3); print "$$x $$y\n";
I hope this helps :-)
(The obvious real solution is that substr() should check the refcount of the PVLV-object and create a fresh one if someone is still holding a reference to the previous one)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: LVALUE refs
by Elian (Parson) on Feb 16, 2003 at 16:03 UTC | |
by xmath (Hermit) on Feb 16, 2003 at 19:49 UTC | |
by Elian (Parson) on Feb 20, 2003 at 16:32 UTC | |
|
Re: Re: LVALUE refs
by BrowserUk (Patriarch) on Feb 16, 2003 at 19:31 UTC | |
by xmath (Hermit) on Feb 16, 2003 at 19:56 UTC |