#!/usr/bin/perl -w # # Given a .csv file, and a start and end time as arguments, print the # correct "part" file, the adjusted start time, and the duration to # stdout. # use strict; # Get PATH set to include this script's directory and other useful bits my $newpath=`dirname $0`; chomp($newpath); $newpath=`$newpath/echo-path`; chomp($newpath); $ENV{'PATH'}=$newpath; if (scalar(@ARGV) != 3) { die "usage: mpgfile keepfile\n"; } my $csvfile = $ARGV[0]; my $startime = $ARGV[1]; my $endtime = $ARGV[2]; my $ch; open($ch, '<', $csvfile) || die "Cannot read $csvfile\n"; my @times; while (<$ch>) { chomp; my @seg = split(/,/,$_); if (($seg[1] <= $startime) && ($seg[2] >= $endtime)) { my $adjtime = sprintf("%06f",$startime - $seg[1]); my $duration = sprintf("%06f",$endtime - $startime); my $partfile = $seg[0]; print "$partfile $adjtime $duration\n"; last; } } close($ch);