#!/usr/bin/perl if ($#ARGV != 0 ) { print "Usage: $0 needs 1 arguments: \n"; exit(); } $file1 = $ARGV[0]; @id = ( ); @yinit = ( ); @phiint = ( ); @yfinal = ( ); @phifinal = ( ); open(FILE1,"<$file1"); while ($line = ) { push(@id, $line); $counter++; } #print "counter is $counter\n"; close(FILE1); $k = 0; $parity = 2; $binvar = 0; while ($k < 1) { if ($id[$k] =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) { $shiftinit = $1; $initsolpattern = $7; $shiftfactor = $9; } $k++; } $start = $shiftinit; $counter1 = 0; while ($start < $counter) { if (($id[$start] =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) && ($start != 0)) { $ynot = $3; $phinot = $4; if($binvar == 0) { push(@yinit, $ynot); push(@phiinit, $phinot); # print "$ynot\t $phinot\t start is $start\t binvar is $binvar\t parity is $parity\n"; } else { push(@yfinal, $ynot); push(@phifinal, $phinot); # print "$ynot\t $phinot\t start is $start\t binvar is $binvar\t parity is $parity\n"; } } if($parity%2 == 0) { $start = $start + $initsolpattern - 1; $binvar = 1; } else { $start = $start + $shiftfactor + 2 - $initsolpattern; $binvar = 0; # $counter1++; TESTING PURPOSES } $parity++; $counter1++; } #print "Y_0 Phi_0 Y_F Phi_F\n"; for ($i=0; $i<$counter1; $i++) { print "$yinit[$i]\t $phiinit[$i]\t $yfinal[$i]\t $phifinal[$i]\n"; #printf ("%12.11f %11.9f\n", $yfinal[$i], $phifinal[$i]); TESTING PURPOSES }