On 8/1/07, Somu <[EMAIL PROTECTED]> wrote:

> Cant we use this to store arrays?

To what does the word "this" refer? To the dbmopen function, somehow,
for that was the whole of the subject line? Or to the code which
follows? Or both?

> Example:
>  [EMAIL PROTECTED];

No; that code will evaluate the "name" of an array in a scalar
context, storing the number of elements in the array into the hash.

>  i'm getting errors..

Is there a reason you're keeping the error message text, and your
actual code, secret from us? If we saw those things, we might be able
to help.

> Which will be a good alternate? Joining the
> array elements and saving as a string to be parsed later or saving a
> ref to the array?

A lot depends upon what you're really trying to do, and I can only
guess at that. But if you want to use a dbm file as the underlying
data structure, you shouldn't store a reference into it; maybe you
want to use join and split:

    # Store a list of items into a single hash slot
    $dbm_hash{$key} = join "\0", @data_items;

Elsewhere....

    # Extract the list of items to an array
    my @extracted_items = split /\0/, $dbm_hash{$key};

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


  • dbmopen Somu
    • Re: dbmopen Tom Phoenix

Reply via email to