in reply to Changing -> to work within a string

Why use an OO-interface at all if you don't want you're users to have to understand this. If you just give them the vars $machine_workdir and $machine_software_version they are happy. If you want something advanced you could try giving them a hash %machine which is tie'ed to some object instead of blessed to an object. This will be less transparent, but it is easier to use unexperienced users (just don't tell them about the tie ;) ).
--
Jaap Karssenberg || Pardus (Larus)? <pardus@cpan.org>
>>>> Zoidberg: So many memories, so many strange fluids gushing out of patients' bodies.... <<<<

Replies are listed 'Best First'.
Re: Re: Changing -> to work within a string
by shushu (Scribe) on Mar 19, 2003 at 18:02 UTC
    Well, Thanks everybody.
    It seems that using tie is the right direction.
    But now I will make it harder...
    The same $machine object does not only have attributes I can use, it also has methods I can execute.
    $machine->shell("ls " . $machine->work_dir);
    Will execute the "ls" on the work directory. Using the tie I would want to write
    $machine->shell("ls $machine{work_dir}");
    The problem is - I actually have two variables - an object $machine, and a hash %machine. But the user don't know it, and I want the user to be able to wrap this line like this:
    sub do_ls { my $machine = shift; $machine->shell("ls $machine{work_dir}"); }
    If the user will need to do double shift, it will ruin the whole idea.
    Any ideas ?
    TIA,
    shushu TIA, shushu