#!/usr/bin/perl -w

use strict;

sub trim_spaces {
	my ($str) = @_;
	return $str;

	$str =~ s/\s+$//;
	$str =~ s/^\s+//;
	return $str;
}


while (<>) {
	chomp;
	next if /^\s*#/;	# Ignore lines with comments.
	next if /^\s*$/;	# Ingnore empty lines.
	s/#.*//;		# Remove comments
	if (/^\s*\[(.*)\]\s*$/) {
		my $sec = &trim_spaces($1);
		print "section name: '$sec'\n";
		next;
	} elsif (/^\s*(.*)\s*=\s*(.*)\s*$/) {
		my $attr = &trim_spaces($1);
		my $val = &trim_spaces($2);
		print "attribute '$attr' equals '$val'\n";
		next;
	} else {
		print "Line $. invalid: '$_'\n";
	}
}
