#!/usr/bin/perl -w

use strict;

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

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


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