I didn't notice Scott Hutton's Config::IniFiles, and just want to share it anyway.

Put the inputs into a HASH.
HASH values modification is forbidden.
Blanks are cool.
Perl comments (#) are also cool.

use ModestIniFile; my %addresses; tie %addresses, ModestIniFile, 'addresses.ini';
package ModestIniFile; use strict; sub die_msg{ ' at ' .( join ' line ', @_[1,2] )."\n" } sub TIEHASH{ my ($class, $file) = @_; open IN, $file or die "File $file does not exist!".die_msg caller; my %ini = map{ split /\s+:\s+/ } grep !/^\s*$/ && !/^[ \t]*#/, <IN +>; bless [ sub{ $ini{ $_[0] } }, sub{ keys %ini }, sub{ each %ini }, +sub{ scalar %ini }, sub{ undef %ini } ], $class } sub FETCH{ $_[0][0]->($_[1]) } sub STORE{ die "Illegall attempt to store INIHash ".die_msg caller } sub DELETE{ die "Illegall attempt to delete from INIHash ".die_msg cal +ler } sub CLEAR{ die "Illegall attempt to clear INIHash ".die_msg caller } sub EXISTS{ $_[0]->FETCH($_[1]) } sub FIRSTKEY{ &{ $_[0][1] }; &{ $_[0][2] } } sub NEXTKEY{ &{ $_[0][2] } } sub SCALAR{ &{ $_[0][3] } } sub DESTROY{ &{ $_[0][4] } } 1;

In reply to IniFiles by strictvars

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.