UPDATE: Sorry I think I messed up here.
Is this something like you want?
My brain is hurting today.
use strict;
use warnings;
while (<DATA>)
{
next unless /\S/;
chomp;
my ($name, $markerA, $markerB, $height)
= split (/\s+/,$_);
$name //= "";
$markerA //= ""; $markerA ="" if $markerA =~ /^0$/;
$markerB //= ""; $markerB ="" if $markerB =~ /^0$/;
if ($markerA !~ /A/)
{
$markerA = $markerB;
$markerB = "B";
}
$height //= "";
if (!$height)
{
my $string;
foreach ($name, $markerA, $markerB)
{
$string .= "\'$_\',";
}
chop $string;
print "$string\n";
}
}
=prints
'2','A',''
'3','','B'
=cut
#Name Marker1 Marker2 Height Time
__DATA__
1 A A 6246 0.9706
1 B B 3237 0.9706
2 A 0
2 B B 5495 0.9775
3 A A 11254 0.9694
3 B 0
I think this could be done better.
Below was a admittedly failed bogus solution for first post.
use strict;
use warnings;
my %name;
while(my $line =<DATA>)
{
next unless $line =~ /\S/; #skip blank lines
chomp $line;
my ($undef, $markerName,undef,
undef, $height) = split (/\s+/, $line);
$name{$markerName} = $height;
}
foreach (sort keys %name)
{
print "$_ => $name{$_}\n";
}
=prints
a => 55
b => 32
c => 34
=cut
__DATA__
1 a 23 99999 55
4 c 55 8888 34
5 b 45 88888 32