#!/usr/bin/perl -w
use strict;

my ($PRINTIT, @linearray, %linehash, $line, $i, $thisPrice);
while (<>){
    chomp;

    if ( $_ =~ /FactorGroup/){
# Process equity_data only

	$_ =~ s/\((property|index|value),(string|double|date|int)\)//g;
	@linearray = split /,/,$_;
	for $i ( 0 .. scalar(@linearray) - 1){
	    $linehash{$linearray[$i]} =  $i;
	}
    }
    else{
	@linearray = split /,/,$_;
	if ( $_ =~ /equity_data/){
	    print "\n" . $linearray[$linehash{"Name"}];
	}
	@linearray = split /,/,$_;
	if ( defined $linehash{"SplitFactor"} && $linearray[$linehash{"SplitFactor"}] -0 > 0 ){
	    $thisPrice = $linearray[$linehash{"Value"}] * $linearray[$linehash{"SplitFactor"}] ;
	}
	else{
	    $thisPrice = $linearray[$linehash{"Value"}];
	}
	print "|". $linearray[$linehash{"Date"}] ."|" .$thisPrice;
    }
}

