Steve Bertrand wrote:
I also really like your suggestion of putting the hashes within a sub.
This will prevent the reset of ALL the data types each time new tests
are run.


You may want to look at dclone() from Storable. It clones deeply nested structures.

#!/usr/bin/perl

use strict;
use warnings;

# See `perldoc English`
use English qw( -no_match_vars ) ;  # Avoids regex performance penalty

use Data::Dumper;
# Make Data::Dumper pretty
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Indent   = 1;
$Data::Dumper::Maxdepth = 0;

use Storable qw{ dclone };

my @a = (
  [ 1, 2, 3, ],
  [ 4, 5, 6, ],
);

my @b = @a;
my @c = @{ dclone( \...@a ) };

print "Initial\n";
print Dumper \...@a;
print Dumper \...@b;
print Dumper \...@c;

$a[1][1] = 'X marks the stop';

print "Modified\n";
print Dumper \...@a;
print Dumper \...@b;
print Dumper \...@c;

__END__

--
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

Regardless of how small the crowd is, there is always one in
it who has to find out the hard way that the laws of physics
applies to them too.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to