Multi-Dimensional arrays, DBMs, and Assoc. Arrays 
Author Message
 Multi-Dimensional arrays, DBMs, and Assoc. Arrays

I have a couple of perl scripts that I am working on that have
the same basic requirement of storing data into a 2-dimensional
table/array/database.  In associative array terminology, I have
multiple values that I want to store with each key.

For example:

Part #    Cost    Color   Qty   Velocity
--------  -----  -------- ----  -------
VW         10     orange   7     59
SR-71    100000   black    1     3620

I understand that Perl 5 has better support for multi-dimensional
arrays.  However, I would like to use associative arrays and
store data in dbm files.  How can I do this?

The best I can think of is using one unique value (part number)
as the key, and creating a tab-seperated string for the value
part.  Is there a better way?

I have even thought that some manipulations may be easier
by converting (key, tab-seperated-string) to and from an
perl 5 multi-dimensional array.

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



Mon, 09 Feb 1998 03:00:00 GMT  
 Multi-Dimensional arrays, DBMs, and Assoc. Arrays

Quote:

>   I have a couple of perl scripts that I am working on that have
>   the same basic requirement of storing data into a 2-dimensional
>   table/array/database.  In associative array terminology, I have
>   multiple values that I want to store with each key.

>   I understand that Perl 5 has better support for multi-dimensional
>   arrays.  However, I would like to use associative arrays and
>   store data in dbm files.  How can I do this?

>   The best I can think of is using one unique value (part number)
>   as the key, and creating a tab-seperated string for the value
>   part.  Is there a better way?

I don't think so.  You can only store strings in a dbm file, so if you want
multiple values you must encode them in a string somehow.

Unpacking might be faster than splitting on tabs.  Or not.

If you want "automatic" encoding you could try the FreezeThaw module
but it's probably no faster than doing join/split yourself.

-Tom



Thu, 12 Feb 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Are Multi-dimensional assoc arrays w/ DBM possible?

2. Are Multi-dimensional assoc arrays w/ DBM possible?

3. arrays, multi-dimensional arrays, pointers and such

4. Associative arrays and multi-dimensional arrays.

5. Extracting an array out of a multi-dimensional associative array

6. 2-dimensional array into 1 dimensional array?

7. Multi-dimensional arrays.

8. multi-dimensional arrays in Perl 5

9. Multi dimensional arrays

10. Multi-Dimensional Arrays

11. Multi-dimensional arrays

12. MULTI-DIMENSIONAL Arrays

 

 
Powered by phpBB® Forum Software