in reply to making a text file to an hash array

There are many ways to do so, and the solution (of course) depends on your requirements. Based on your example, try the following approach:

  1. read the text-file into one string
  2. split the string based on your delimiter (which seems to be a blank). This will give you an array
  3. Pass through the array.
    • check if the current element is a key (a single letter in your example, use =~ /\w/)
    • if yes: check if the next element is a value
      • if yes: store the value to the hash (using the key identified before)
      • if no: store an empty value to the hash (using the key identified before)
    • continue with the next element

Of course you can optimize. And probably you have to adapt the algorithm - but I hope it gives you an idea!

Rata

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.