On 16/10/2011 19:10, JPH wrote:

On 10/16/2011 04:05 AM, Shawn H Corey wrote:
On 11-10-15 07:44 PM, Rob Dixon wrote:

sub try {
my @b;
foreach my $row (@_) {
push @b, [@$row];
}
:
}


Or you could use dclone() from Storable:

use Storable qw( dclone );

sub try {
my @b = @{ dclone( \@_ ) };
...
}

Storable is a standard module that is installed with Perl. For a list
of all standard pragmatics and modules, see `perldoc perlmodlib`.

Thanks! My script seems to work with dclone.

Though the (deep) recursion takes a lot of time ...
What is your opinion, would it pay off (in performance) when I rewrite
the script in such a way that I do not use dclone, but string
manipulation routines instead? So:
- passing a single dimension array containing 16 elements with
16-character strings and doing substr()
- instead of passing a 2 dimensional (16x16) array passing 1-character
strings and doing dclone
Every pass I only change a single character, then I run some tests and
so on.

I suggest you try a simplified version of my code, which is bound to be faster than calling dclone:

  sub try {
    my @b = map [@$_], @_;
    :
  }

Whether it is fast enough only you can tell.

I would also suggest an intermediate solution, where you have a
sixteen-element array, each of sixteen characters. Rather than using
substr you could look at unpack, or possibly split and join.

It is hard to help you further without knowing more about the problem
you are solving.

Rob

--
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