#! perl -slw use strict; package scalarObj; my $scalar; sub new{ return bless \$scalar, shift; } package arrayObj; my @private = qw(1 a the 3.14159); sub new { return bless \@private, shift; } package hashObj; sub new { return bless {some=>1, things=>2, in=>3, a=>4, hash=>5 }, shift; } package main; use Data::Dumper; my @objects = ( new scalarObj, new arrayObj, new hashObj ); foreach my $obj (@objects) { print Dumper $obj; } __END__ C:\test>217134 $VAR1 = bless( do{\(my $o = undef)}, 'scalarObj' ); $VAR1 = bless( [ '1', 'a', 'the', '3.14159' ], 'arrayObj' ); $VAR1 = bless( { 'things' => 2, 'a' => 4, 'some' => 1, 'hash' => 5, 'in' => 3 }, 'hashObj' ); C:\test> #### #! perl -slw use strict; package scalarObj; my $scalar= 'test'; sub new{ return bless \$scalar, shift; } package arrayObj; my @private = qw(1 a the 3.14159); sub new { return bless \@private, shift; } package hashObj; sub new { return bless {some=>1, things=>2, in=>3, a=>4, hash=>5 }, shift; } package main; use Data::Dumper; my @objects = ( new scalarObj, new arrayObj, new hashObj ); foreach my $obj (@objects) { if ($obj =~ /scalar/) { print $$obj; } elsif($obj =~ /array/) { print "@{$obj}" } elsif($obj =~ /hash/) { print "$_ => $obj->{$_}" for keys %$obj; } } __END__ C:\test>217134 test 1 a the 3.14159 things => 2 a => 4 some => 1 hash => 5 in => 3 C:\test>