use strict;
use warnings;
use Data::Dumper;
open my $fh, '<', "my.ini" or die "$!\n";
my $ini = {};
{
local $/ = "";
while (<$fh>) {
next unless ( s/\[([^]]+)\]// );
my $header = $1;
$ini->{$header} = {};
while (m/(\w+)=(.*)/g) {
$ini->{$header}->{$1} = $2;
}
}
}
close $fh;
print Dumper $ini;
__DATA__
[Build]
BuildID=20110209115208
Milestone=2.0b11
SourceStamp=f9d66f4d17bf
SourceRepository=http://hg.mozilla.org/mozilla-central
; This file is in the UTF-8 encoding
[Strings]
Title=SeaMonkey Update
Info=SeaMonkey is installing your updates and will start in a few
moments
use warnings;
use Data::Dumper;
open my $fh, '<', "my.ini" or die "$!\n";
my $ini = {};
{
local $/ = "";
while (<$fh>) {
next unless ( s/\[([^]]+)\]// );
my $header = $1;
$ini->{$header} = {};
while (m/(\w+)=(.*)/g) {
$ini->{$header}->{$1} = $2;
}
}
}
close $fh;
print Dumper $ini;
__DATA__
[Build]
BuildID=20110209115208
Milestone=2.0b11
SourceStamp=f9d66f4d17bf
SourceRepository=http://hg.mozilla.org/mozilla-central
; This file is in the UTF-8 encoding
[Strings]
Title=SeaMonkey Update
Info=SeaMonkey is installing your updates and will start in a few
moments
No comments:
Post a Comment