Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find values in a file

Status
Not open for further replies.

donny750

Programmer
Joined
Jul 13, 2006
Messages
145
Location
FR
hello,

Somebody can help,look me where i must look information for doing this :

I've file
values.txt
#------------------
#Important
#------------------

export scan=YES
export vinils=/home/vinils
export dayof=NO

#------------------
#sub
#------------------

export var1=easy
export var2=medium
export var3=hard

and i want to recover the values of the variables
in the best world i want to take him in a array like this
Code:
%values ("scan" => "YES",
"vinils" => "/home/vinils",
"dayof" => "NO",
....
"var3" => "hard"
);

it's possible ?

thanks
 
NO, it's not impossible.

Yes, the order is lost if you save the data in a %hash. But this can be solved by saving it in an alternate data structure such as an array of arrays refs. Or you can keep a secondary data structure which is an array with the order of the keys, that way still getting the benefits of the quick hash lookup while saving the ordering information.

Whatever specification that you have can be met. You simply have to account for it in your code.
 
Yes with hash it's impossible, you can only sort the key list, but what for a sense should that have for you? For a hash it's insignificant.
 
>> Yes with hash it's impossible, you can only sort the key list, but what for a sense should that have for you? For a hash it's insignificant.

Hashes can be sorted anyway you want: by the keys or by the values, or parts of the keys or values, by the keys and the values or values and the keys, etc etc etc.

- Kevin, perl coder unexceptional!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top