On 10/5/05, Ovid <[EMAIL PROTECTED]> wrote:
> sub _attributes {
> my ($self, $attrs) = @_;
> return $$attrs if UNIVERSAL::isa( $attrs, 'SCALAR' );
>
> my @attributes = UNIVERSAL::isa( $attrs, 'HASH' )
> ? %$attrs : @$attrs;
> return unless @attributes;
> # more code here
> }
>
> This was a private method, but $attrs is an argument that is passed in
> by the person using my class. It would be nice if I could just assign
> an "attributes" role to the SCALAR, ARRAY, and HASH classes and say
> that only my class could see the method(s) it provides. Thus, my
> caller would be blissfully unaware that I am doing this:
>
> $attrs->attributes; # even if it's an array reference
sub _attributes($ref) {
my multi attributes ($scalar) { $$scalar }
my multi attributes (@array) { @array }
my multi attributes (%hash) { %hash }
attributes($ref)
}
That attributes look suspiciously indentityish. There is some context
magic going on.
Or doesn't this solve your problem?
Luke