I've been reading quite a bit of docs the last few days, and in
"perltooc", I came across some neat tricks. Admittedly though, although
I understood it well enough to get excited about some of the techniques,
a reasonable portion of the details flew above my head (at this time).

One issue I've been dealing with is updating my modules with accessors,
instead of my applications using the instance variables directly.

In the mentioned perldoc, there are snips of code showing how to update
the symbol table to reference a subroutine with the same name as each
key in an object's hashref. In my case, it'd look something like this:

for my $datum (keys %User) {
    no strict "refs";

    *$datum = sub {
        shift; # drop the caller
        $User{$datum} = shift if @_;
        return $User{$datum};
    }
}

If I understand correctly, if I've done the above, and currently  have this:

$user->{'username'} = 'steveb'; # in an app

I could then replace it instead with:

$user->username('steveb');

I'm not asking for a lack of trying. I'm just trying to ensure I
understand correctly so far, and if so, if I change my internal names, I
could then create 'alias' entries that point the old name to the new
instance variable.

Steve

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to