I am new to Perl, I wanted to combine two lines where "ANN" and "QTR" in second column have same date in fourth column (date), otherwise just print line with data which has "ANN" in it. It also skip line where date column is empty:
Input data file:
I am new to Perl, I wanted to combine two lines where "ANN" and "QTR" in second column have same date in fourth column (date), otherwise just print line with data which has "ANN" in it an then sort data based on first field. It also skip line where date column is empty:
Input data file
==================
SEC ANN -11 19831117
SEC ANN -11 19831215
SEC QTR -11 0
SEC ANN 1 0
SEC QTR -1.17 0
SEC QTR 1.11 0
SEC QTR 1.66 19861218
SEC ANN -1.36 19860116
SEC ANN -1.52 19861120
SEC ANN -1.52 19861218
SEC QTR 1 0
SEC QTR -1.16 0
SEC QTR 1.12 19860116
output would like like this:
==========================
SEC 19831117 -0.07 0
SEC 19831215 -0.07 0
SEC 19860116 -1.36 1.12
SEC 19860220 -1.36 0
SEC 19861120 -0.52 0
SEC 19861218 -1.52 1.66
SEC ANN -11 19831215
SEC QTR -11 0
SEC ANN 1 0
SEC QTR -1.17 0
SEC QTR 1.11 0
SEC QTR 1.66 19861218
SEC ANN -1.36 19860116
SEC ANN -1.52 19861120
SEC ANN -1.52 19861218
SEC QTR 1 0
SEC QTR -1.16 0
SEC QTR 1.12 19860116
output would like like this:
SEC 19831117 -0.07 0
SEC 19831215 -0.07 0
SEC 19860116 -1.36 1.12
SEC 19860220 -1.36 0
SEC 19861120 -0.52 0
SEC 19861218 -1.52 1.66