use Data::Dumper; use Devel::Size qw(total_size); my $bigfoo = 'foo' x 1_000; my @assigned = $bigfoo =~ /(foo)/g; my @pushed; push @pushed, $1 while $bigfoo =~ /(foo)/g; printf "pushed: %d\n", total_size( \@pushed ); printf "assigned: %d\n", total_size( \@assigned ); if ( Dumper( \@pushed ) eq Dumper( \@assigned ) ) { print "They look the same.\n"; } else { print "They look different.\n"; } __END__ pushed: 52132 assigned: 32052 They look the same. #### pushed: 32132 assigned: 32052