P0w3rK!d has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to apply this to .inf files from install shield which have nearly the same format as .ini files. I have not been able to determine how to modify it in order to ignore the parsing of parameters which modify the regsitry.

For example:

[section] parameter=123 [foo_delreg] HKLM,"SYSTEM\foo\bar\joe\bob","WEB"
When it reads the ",", I get the following error:

Can't call method "val" on an undefined value at line 109.

# using: my $cfg = new Config::IniFiles( -file => 'C:\temp\Foo.inf' ); print "We have parm " . $cfg->val( 'section', 'parameter' ) . "." if $cfg->val( 'section', 'parameter' );

Any idea where I need to make the modification to IniFiles.pm? Thanks in advance. :)
-P0w3rK!d

REF: Config::IniFiles Module

Replies are listed 'Best First'.
Re: Config::IniFiles modification
by krisahoch (Deacon) on Oct 10, 2002 at 22:11 UTC

    Dude,

    You might want to extend Config::IniFiles instead of changing it directly. I do this from time to time because authors tend to fix bugs, and I sometimes upgrade. Poof, there go my changes.

    It is also a great learning exercise (if you need it). Call you module Config::IniFiles::InstallShield or something, and override ReadSub with your own that parses this type of file correctly.

    Just my two cents.
    Kristofer
    PS. I'd have done this but we use InstallAnywhere (xml config files)

      Thanks Dude,

      This is a side project for Install Shield 6.1 and Install Shield Package for the Web.
      Once we've extended something, what's the process around here or on CPAN to get it to everyone?

      -P0w3rK!d

        I saw 'How to make a CPAN Module Distribution' in the tutorials section, but have never personally made one. All of my extensions are proprietary stuff and not really reusable outside of my Company

        Give it a shot. Before you post it however, you may want to read up on InstallSheild's documentation to make certain that you have covered everything (IE doesn't crash if /^HKCU/ is found as well as /^HKLM/.

        Kristofer

Re: Config::IniFiles modification
by P0w3rK!d (Pilgrim) on Oct 10, 2002 at 21:20 UTC
    Found it...
    sub ReadConfig() ... while(@lines) ... # Store what our line ending char was for output ($self->{line_ends}) = $lines[0] =~ /([\015\012\025\n]+)/; while ( @lines ) { $_ = shift @lines; s/(\015\012?|\012|\025|\n)$//; # remove line ending + char(s) $lineno++; if (/^\s*$/) { # ignore blank lines next; } # added this... ignore registry values elsif (/^HKLM/) { next; } ...
    It works now. Thank you :)