in reply to Application Deployment With Perl

MrChromeDome, if you wanted to go the XML route instead of an ini file I'd take a peek at XML::Simple. You could replace your ini file with this:
<?xml version="1.0"?> <Config> <Assessor>1.5.499</Assessor> <LOCAL_PATH>d:\pb8\</LOCAL_PATH> <SYSTEMS>Assessor,Treasurer</SYSTEMS> <Treasurer>1.5.200</Treasurer> <ZIP_PATH>p:\</ZIP_PATH> </Config>
Then in your read_ini subroutine, parse the XML:
sub read_ini { my $config_file = shift; my $parser = XML::Simple->new; my $results = $parser->XMLin($config_file); # $results is a hash reference return $results; }
You'll have to take into account the fact that read_ini will now be returning a hash reference instead of a plain hash:
my $config = read_ini("AppDeployment.xml");
And then...
my $apps = $config->{SYSTEMS};
Hope that helped.

Update: fixed typo, thanks buttroast.

-- vek --

Replies are listed 'Best First'.
Re: Re: Application Deployment With Perl
by MrCromeDome (Deacon) on Apr 03, 2003 at 19:52 UTC
    Is it possible, for example, to do something like this:
    <?xml version="1.0"?> <Config> <LOCAL_PATH>d:\pb8\</LOCAL_PATH> <ZIP_PATH>p:\</ZIP_PATH> <SYSTEMS> <Assessor>1.5.499</Assessor> <Treasurer>1.5.200</Treasurer> </SYSTEMS> </Config>
    If I'm thinking of it right, I could see that I have a list of systems, and if I delve into the systems I could find various properties of them, such as version, etc.?

    Thanks for the info :) Very informative :)
    MrCromeDome

      Yep it's entirely possible to do what you suggest. Here's the data structure that XML::Simple would create (results dumped via Data::Dumper):
      $VAR1 = { 'ZIP_PATH' => 'p:\\', 'LOCAL_PATH' => 'd:\\pb8\\', 'SYSTEMS' => { 'Treasurer' => '1.5.200', 'Assessor' => '1.5.499' } };
      And then:
      my $config = read_ini("AppDeployment.xml"); my $assessor_version = $config->{SYSTEMS}->{Assessor};
      -- vek --
Re: Re: Application Deployment With Perl
by buttroast (Scribe) on Apr 12, 2003 at 02:10 UTC
    vek, I tried to use your XML read_ini sub on a WIN32 but it choked on XMLIn. Changed it to XMLin and it worked fine.
      buttroast, cheers, it was a typo and should have been XMLin

      -- vek --