#!/usr/local/bin/perl

# select Output from .s - files

if($#ARGV <0){
    print "\nusage: sels <file> <cell> {<m>}\n\n";
    print "       reads <file>  \n";
    print "       selects <cell>\n"; 
    print "       selects steps modulo <m>\n\n"; 
}

$in=$ARGV[0]   ;
$cl=$ARGV[1];
$md=$ARGV[2];
if($md == 0){
    $md=1;
}

die "File $in not found." unless -f $in;
open(INP,$in);
$w=1;
while(<INP>){
    if(m/=====/){
	split(' ');
	$c=$_[2];
	chop $c;
	$s=$_[4];
	if($c eq $cl && ($s % $md == 0) ){
	    $w=1
	}
	else{
	    $w=0;
	}
    }
    if($w){
	print;
    }
}
