I raised this question sometime back but I did not get much of a response,
and as perl5.002 is looming I thought I would raise it again.
The situation arises when I want to use a reference to a GLOB to
represent a blessed object so that I can use the scalar, array and
hash parts of the GLOB inside the package.
When it comes to accessing these elements I currenly have 2 options
sub some_method {
my $self = shift;
local *me = *$self;
$me{some_element};
}
which can be confusing as bot C<me> and <self> represent the object, C<me>
is used to change to contents and C<self> for calling other methods.
or
sub some_method {
my $self = shift;
print ${%{*$self}}{fred},"\n";
}
which just looks disgusting ;-)
My question is how many people would object to
$ref->{}
$ref->[]
$$ref
automatically de-referenceing to the required part of the GLOB instead of
croaking with a message like
Not a HASH reference at ./tst line 9.
Regards,
Graham.
--
Graham Barr <bodg@tiuk.ti.com>
Texas Instruments Ltd.
and as perl5.002 is looming I thought I would raise it again.
The situation arises when I want to use a reference to a GLOB to
represent a blessed object so that I can use the scalar, array and
hash parts of the GLOB inside the package.
When it comes to accessing these elements I currenly have 2 options
sub some_method {
my $self = shift;
local *me = *$self;
$me{some_element};
}
which can be confusing as bot C<me> and <self> represent the object, C<me>
is used to change to contents and C<self> for calling other methods.
or
sub some_method {
my $self = shift;
print ${%{*$self}}{fred},"\n";
}
which just looks disgusting ;-)
My question is how many people would object to
$ref->{}
$ref->[]
$$ref
automatically de-referenceing to the required part of the GLOB instead of
croaking with a message like
Not a HASH reference at ./tst line 9.
Regards,
Graham.
--
Graham Barr <bodg@tiuk.ti.com>
Texas Instruments Ltd.