Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Reading from an INI file

by jeroenes (Priest)
on May 15, 2001 at 18:52 UTC ( [id://80549]=note: print w/replies, xml ) Need Help??


in reply to Reading from an INI file

Hashes are much better here! Main reason: you don't want to pollute your namespace with names that can pop up in those INI files. Well, actually, you want it now, but after some experience with the results, you will want that you didn't want it now. {grin}

With an example:

my %ini; @file = grep m/^[^#]/, @file; #skips comments for (@file){ chomp; #mpolo is right! my ($key, $val) = split /=/,2; #splits the line $ini{ $key } = $val if $key; #if we have a key, store }
In the remainder of the code, use $ini{$key} to access the ini values.

You can read up in perldata.

Hope this helps,

Jeroen
"We are not alone"(FZ)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://80549]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-23 20:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found