in reply to Tie() and substr(), proposal for SUBSTR tie object method

I'd also like to see a FETCHPRINT method that's called when someone prints a tied variable, a FETCHMATCH method for when someone wants to match a regexp against the tied variable, a FETCHKILL variable if someone wants to kill a process whose process id is stored in a tied variable, a FETCHSIGNAL for when someone wants to use a tied variable as the signal number to the kill function, and some magical setting to solve the conflict if both the signal number and the process id are tied variables...

  • Comment on Re: Tie() and substr(), proposal for SUBSTR tie object method

Replies are listed 'Best First'.
Re^2: Tie() and substr(), proposal for SUBSTR tie object method
by ysth (Canon) on Jul 03, 2005 at 07:46 UTC
    Did you even read the OPs reasons for suggesting special handling for substr? If you had, you would have suggested only FETCHVEC.

      You are right.

      But seriously, I think this isn't the task of tie, rather, it's that of operator overloading. Besides the stringification operator, there could be an overloadable substr operator, which would return a part of the string. (Similarly there could be a print operator too, which would print the object. The match and kill thingy is stupid.) Then, the tied variable (which could be scalar, or array etc) could return an overloaded object. This, however, is probably still not a very good idea because, as dave_the_m explained, it would cause incomaptibilities.