#!/usr/bin/perl; use strict; use warnings; my $typles_ref1; if(function(\$typles_ref1,"array")) { print "ARRAY:\n"; print join(', ',@$typles_ref1)."\n"; } my $typles_ref2; if(function(\$typles_ref2,"hash")) { print "HASH:\n"; while(my($k,$v)=each(%$typles_ref2)) { print "$k = $v\n"; } } ###################################################### sub function { my($ref,$type)=@_; return 0 if($type ne 'array' and $type ne 'hash'); $$ref=[qw(var1 var2 var3)] if($type eq 'array'); $$ref={qw(key1 var1 key2 var2)} if($type eq 'hash'); return 1; }