$ARGV0 = shift @ARGV; print < EOF # print the mapping open ( NAMESPACES, $ARGV0 ) || die "can't open namespace file: $!"; $group = 0; $i = 1; while ( ) { chomp( $_ ); $_ =~ s/\s*//g; if ( $_ =~ m/^$/ ) { # Start a new group $i = 0; $group++; } elsif ( $_ =~ m/^[^#]/ ) { # Neither an empty line nor a comment $_ =~ /^[a-zA-Z0-9-_]+$/ or die "Invalid namespace token $_"; $_ =~ s/-/_/g; $no = $group*10 + $i; print < $no EOF ++$i; } } print < EOF