use strict; use warnings; use Test::More; my ($pos1,$pos2)=("a","a"); # *** Those should pass suite(\$pos1,\$pos1); # *** Those should fail suite(\$pos1,\$pos2); done_testing; # --- my tests for various scalar refs sub suite { my ($ref1,$ref2) = @_; is_deeply( scr($ref1), scr($ref2), "is_deeply"); is_deeply( scr([$ref1]), scr([$ref2]), "is_deeply ARRAY"); is_deeply( scr({t=> $ref1}), scr({t=>$ref2}), "is_deeply HASH"); is_deeply( scr({t => [$ref1]}), scr({t => [$ref2]}), "is_deeply HoA"); is_deeply( scr({t => [$ref1,$ref1], t2 => [$ref1]}), scr({t => [$ref2,$ref2], t2 => [$ref2]}), "is_deeply HoA multiple refs"); } # --- stringify_scalar_refs sub scr { my ($ref) = @_; my $reftype = ref $ref; if( $reftype eq 'SCALAR') { $$ref = "$ref"; } elsif ( $reftype eq 'ARRAY') { for my $el (@$ref) { scr($el); } } elsif ( $reftype eq 'HASH') { while (my ($key,$val) = each %$ref ){ scr($val); } } else { ... # dunno yet } return $ref }