#!/usr/bin/perl -w use strict; sub get_stuff { my $ref = shift; if (ref $ref) { if (ref $ref eq 'SCALAR') { $$ref = 'This is a scalar'; } elsif (ref $ref eq 'ARRAY') { @$ref = qw(This is an array); } elsif (ref $ref eq 'HASH' ) { %$ref = (1 => 'This', 2 => 'is', 3 => 'a', 4 => 'Hash'); } else { die "Invalid reference type passed to get_stuff.\n"; } } else { die "Non-reference passed to get_stuff.\n"; } } my ($scalar, @array, %hash); get_stuff(\$scalar); get_stuff(\@array); get_stuff(\%hash); print "$scalar\n"; $"='|'; print "@array\n"; print map { $hash{$_} . ' ' } sort keys %hash;