#!/usr/local/bin/perl open(RULES, $ARGV[0]) or die "Failed Open : $!\n"; #%GROUP ALSMS_consolidation #%CHPTR ALSMS_consolidation #%SBCH1 WORK_switch_id print "group ^ chapter ^ name ^ description\n"; while() { chomp; @line=split /\s+/; if(/^\%SBCH1/) { foreach my $key (keys %outer) { print "$key: ", join(", ", @{$outer{$key}}), "\n\n"; } %outer=(); } if(/^\%GROUP/) { $group=$line[1]; } if(/^\%CHPTR/) { $chapter=$line[1]; } else { if(/^\%/) { $tag=$line[0]; shift @line; $full = join ' ', @line; push(@{$outer{$tag}}, $full) } } }