#!/usr/bin/perl
#
# Reads raw PVS-Studio logs from stdin and outputs the data a simple human readable text file.
#

use strict;

while (<STDIN>) {
	my $line = $_;
	#drop uneeded constant header info
	$line =~ s/Viva64-EM<#~>full<#~>/<#~>/g;
	# Discard unknown non-human readable data after discription.
	$line =~ s/<#~>false<#~>\d+<#~>/<#~>/g;
	#Reformat the error number discription, line number, file name to more human readable form.
	$line =~ s/<#~>(\d+)<#~>\|\?\|([^>]*)<#~>error<#~>([^>]*)<#~>([^>]*)<#~>/Error $3, $4 At line $1 in: '$2'\n /g;
	$line =~ s/<#~>/\n/g;
	print "$line";
}
