Help for this page

Select Code to Download


  1. or download this
        my %mapping = ( ARRAY  => '@', HASH   => '%', SCALAR => '$',
                        GLOB   => '*', REF    => '$', CODE   => '&' );
        return eval $mapping{$type}.'{$_[0]}';
    
  2. or download this
    return @{$_[0]}   if  $type eq "ARRAY";
    return %{$_[0]}   if  $type eq "HASH";
    return ${$_[0]}   if  $type eq "SCALAR";
    return *{$_[0]}   if  $type eq "GLOB";
    return ${$_[0]}   if  $type eq "REF";
    return &{$_[0]}   if  $type eq "CODE";
    
  3. or download this
    my( $ref )= @_;
    $ref= $$ref   while  UNIVERSAL::isa($ref,"REF");
    ...
    return $$ref   if  UNIVERSAL::isa($ref,"SCALAR");
    return &$ref() if  UNIVERSAL::isa($ref,"CODE");
    return $$ref,@$ref,%$ref   if  UNIVERSAL::isa($ref,"GLOB");