P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You are there, ... almost.
All you have to do is split each element from your array into a key and value part. One possible solution is: %edit = map {split /\s+=\s+/} @data; It doesn't make a hash like you wish (with the strange "e101" keys) but that did not make any sense to me, so I went for a more logical solution: the keys are your variable names and the values are the contents of the variables. But you are re-inventing wheels by making one more configuration handler. Have a look at (for instance) YAML or Config::Auto or Config::Any. CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James In reply to Re: How to copy an array to a hash?
by CountZero
|
|