in reply to Tie() and substr(), proposal for SUBSTR tie object method
First, optional tie methods have the habit of breaking inheritance. Consider a hypothetical popular CPAN module that uses a tied SCALAR. Suppose my code creates a subclass of this, where I override FETCH, with something like
Now suppose that the CPAN maintainer updates his code to include a new FETCHSUBSTR method. I install this version, and suddenly my FETCH method is mysteriously no longer being called.sub FETCH { my $self = shift; do_domething; $self->SUPER::FETCH(@_); }
Second, given the way the perl5 interpreter works, it's not practical to combine array subscripting and substr, so it wouldn't be possible to use *SUBSTR with arrays and hashes.
Lastly, it would help if you explained how the various uses of the substr function were mapped to *FETCH calls, especially when substr is used as an lvalue, eg
$ perl586 -wle 'sub f { $_[0] = "x" } $a = "abcd"; f(substr($a,0,2)); +print $a' xcd
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tie() and substr(), proposal for SUBSTR tie object method
by millueradfa (Initiate) on Jul 11, 2005 at 14:50 UTC |