in reply to More efficient Data Structure needed
A lookup hash is a good idea, as they are faster than iterating through an array. Also, you can do a normal string equality test (eq) rather than compiling the regular expression and firing up the regex engine. Finally, you can use just normal string interpolation rather than join since you're doing nothing too fancy there.
It looks like @data is likewise two-dimensional, so assuming that here's something that might work for you:
my %lookup = map { $_->[0] => $_ } @m_info; # key each array by its fi +rst entry. foreach my $record (@data) { my $data = $lookup{$record->[1]}; $record->[1] = "$data->[3]_$data->[1]" if $data; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: More efficient Data Structure needed
by BrowserUk (Patriarch) on Dec 18, 2002 at 02:43 UTC | |
by djantzen (Priest) on Dec 18, 2002 at 02:58 UTC | |
by iburrell (Chaplain) on Dec 18, 2002 at 17:10 UTC |