Re: partial assignment using lvalue?
[email protected] (Michael Fowler) Tue, 29 Aug 2000 22:37:38 -0800
| Newsgroups | perl.perl6.language.subs |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Aug 30, 2000 at 02:26:08PM +0800, Kenneth Lee wrote: > dear all, > > it seems all the "lvalue sub" RFCs haven't mentioned this. > currently we can do > > $str = "foo bar"; > substr($str, 4, 0) = "baz "; > > and $str will become "foo baz bar". should we be able to do > this with lvalue-subs? how can one returns "pointer" to a > portion of a scalar? The best way to implement this, at least currently, is with a tied scalar that uses substr underneath, or even does things manually. If the lvalue behaviour adopted looks like the kind we now have (where you have to return an lvalueable er, value) returning a tied variable will probably be the only way to control what's assigned. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com --