my $inifile='config.ini' my %words; my $section; open (INI,$inifile) || die "Couldn't open '$inifile': $!\n"; my $section='DEFAULT'; # Somewhere to store the garbage while () { next unless /\S/; next if /^[;'#]/; # Ignore comments chomp; if (/\[(.+)\]/) { $section = $1; } else { $words{$section}{$_}=1; } } close(INI);