I dont wether I got u right. I think this is what you are looking at
#!/usr/bin/perl
#
# Read the entire Data into a single string
#
$/=undef;
$string = <DATA>;
$string=~s/\s+/ /g;
$prev = 0;
while($string=~/(\S+) (\S+) (\S+)/g) {
print "$2 =>($3 - $prev) " . ( $3 - $prev ) . " \n";
$prev = $3;
}
__DATA__
1.40616 tw-
1.51162
1.53491 w-ih
1.55572
1.61759 ihLx
1.70433
1.74422 Lx#
1.91998
1.94224 UU
1.95236
Dennis Warren wrote:
> Hi,
>
> I'm trying to use data to work out the average durations of certain sounds
> for a project here at work. The problem I have is that I'm a real newbie at
> Perl, and I'm finding the data really hard to get my head around. I don't
> really know where to begin. Any suggestions for an approach would be really
> appreciated.
>
> The data, in plain text files, looks something like this:
>
> 1.40616 tw-
> 1.51162
> 1.53491 w-ih
> 1.55572
> 1.61759 ihLx
> 1.70433
> 1.74422 Lx#
> 1.91998
> 1.94224 UU
> 1.95236
>
> The first column is a time in seconds, and the second column (not always
> filled) represents the symbol/sound I'm measuring.
>
> What I need to do is to work out the length of a certain symbol. (the one in
> the 2nd column, e.g. "w-ih"). I have to do this by taking the time in the
> previous record away from the time in the next record to get the duration
>
> 1.40616 tw-
> 1.51162 <- the start time of the symbol to measure
> 1.53491 w-ih <- the symbol to measure
> e.g. 1.5572 - 1.51162 = 0.04558
> 1.55572 <- the stop time of the symbol to measure
> 1.61759 ihLx
> 1.70433
>
> As you can see, the stop time for one sound is very often also the start
> time for the next sound. As well as this I face the problem that the first
> sound in all the records cannot be measured, as it has no start point. So I
> must always ignore this. I want to output the durations of all the symbols
> in a given data set, e.g..
>
> w-ih 0.04558
> ihLx 0.14861
>
>
> Any solutions, or hints at achieving a solution would be great
>
> regards,
>
> Dennis
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]