Hello friends ,
I need to parse some data from a file and arrange it in a certain file..however the file is so confusing and has such minute issues that it has really confused me now..can sumbody help.
Thanks
Aj
I am attaching the main part of the input file which are causing me trouble.
I am using this code :
my @file1 =<INFILE>;
foreach $lines(@file1)
{
if($i==3)
{
$i=1;
print OUTFILE"\\";
print OUTFILE"\n";
}
if ($lines =~m/^\\/)
{
$i=$i+1;
$lines=~s/\\//g;
print OUTFILE"\n";
if ($i==2)
{
print OUTFILE"$lines";
}
}
if($lines =~m/^JASSS:|Date:|Title:/)
{
print OUTFILE"$lines";
}
elsif ($lines =~m/^Author: && ^Address:/)
{
print OUTFILE"\n";
print OUTFILE"$lines";
}
elsif ($lines =~m/^Address:/)
{
print OUTFILE"\n";
print OUTFILE"$lines";
}
else
{
chomp($lines);
print OUTFILE"$lines";
}
}
close (INFILE);
close(OUTFILE);
exit;
OUTPUT comes like this:
ID: 1.1.2
Date: 31 Jan 1998
Title: Qualitative Modeling and Simulation of Socio-Economic Phenomena
Author: Giorgio Brajnik
Address: Dipartimento di Matematica e InformaticaUniversità di Udine Udine Italy Italy
Author: Marji Lines{The author and address shouldn't come together, which doesn't come in this case but if i change the code to get the 2nd record correctly this gets disturbed
Address: Dipartimento di Scienze StatisticheUniversità di Udine Udine Italy 33100 Italy
This paper describes an application of recently developed qualitative reasoning techniques to complex, socio-economic allocation problems.
\
ID: 2.3.3
Date: 30 Jun 1999
Title: Simulating Household Waste Management Behaviours
Author: Peter Tucker
Address: Environmental Initiatives GroupHigh Street PAISLEY PA1 2BE United Kingdom
Author: Andrew Smith
Address: Language Evolution and Computation Research UnitSchool of Philosophy Psychology and Language Sciences University of Edinburgh,{I don't want a new line here but if i change my code to get this correctly the 1st record gets disturbed
Adam Ferguson Building, 40 George Square EH8 9LL Edinburgh, United Kingdom
The paper reports the outcome of research to demonstrate the proof of concept.
NOTE: {I would like to have an output which fulfills both the criteria.}