perlplayer has asked for the wisdom of the Perl Monks concerning the following question:

hello i have a user data file all data of a single user in a single line delimited with '|' Now I am able to split the data and create dynamic hash of hashes from the data . i am working with this hash through out the script but its taking long time to finish as the users are many
My Question 1: Is there a better way to do it such that the run time will be less.
My Question 2: I want to store each user data as a hash in a file like we can store a whole structure in a file in C Lang. In perl is it possible to write that way.
  • Comment on writing hash to a file ...is it possible

Replies are listed 'Best First'.
Re: writing hash to a file ...is it possible
by tokpela (Chaplain) on Jul 23, 2009 at 12:08 UTC

    I recommend you use DBM::Deep.

    Once loaded, it can work just like a hash and is fast.

Re: writing hash to a file ...is it possible
by marto (Cardinal) on Jul 23, 2009 at 11:21 UTC

    "My Question 2: I want to store each user data as a hash in a file like we can store a whole structure in a file in C Lang. In perl is it possible to write that way."

    Perhaps Storable is what you are looking for if you want to reopen these files later within a Perl script.

    Martin

Re: writing hash to a file ...is it possible
by Utilitarian (Vicar) on Jul 23, 2009 at 10:54 UTC
    Q1: Access to a hash of hashes is fast, perhaps your use of the hash of hashes could be speeded up.

    Q2: a text based solution could be:
    use Data::Dumper; to write out and eval the contents to "reload" what has been written out.

Re: writing hash to a file ...is it possible
by ropey (Hermit) on Jul 23, 2009 at 11:27 UTC
    You may find this node helpful.