#!/usr/bin/perl

use strict;
use Getopt::Long;

open CHANNELS, "<channels.conf"
	or die $!;
my(@lines)=<CHANNELS>;

foreach my $line (@lines){
	my @column=split(/:/, $line);
	my @caid=split(/=/, $column[8]);

# this are the names and fild numbers of channels.conf:
# Name: $column[0], Freq: $column[1], Param: $column[2], Src: $column[3], Symb: $column[4],
# VPID: $column[5], APID: $column[6], TPID: $column[7], CAID: $column[8], SID: $column[9],
# NID: $column[10], TID: $column[11], RID: $column[12]

# we have to make shure to print the "data lines" only:

	if((substr($column[3],0,1) eq "C") || (substr($column[3],0,1) eq "S")){
		my @name=split(/;/, $column[0]);
		my @longname=split(/,/, $name[0]);
		$longname[0] =~ tr/\/ /__/;
		$longname[0] = lc $longname[0];
		print "$column[10]-$column[11]-$column[9]:$longname[0]\n";
	}
}

close(CHANNELS);
