Sorry for not being clear with my question. My mistake. Here is the sample of input data I am operating on:
######################### Input file #############################
chn:req cmd:SDP_CMD_RDBLKL tag:0x3b9aca01 addr:0x10000a qospri:0 len:0xf noalloc:0
chn:req cmd:SDP_CMD_RDBLKL tag:0x3b9aca0d addr:0x20000b qospri:0 len:0xf noalloc:0
chn:req cmd:SDP_CMD_RDBLKL tag:0x3b9aca19 addr:0x30000c qospri:0 len:0xf noalloc:0
chn:req cmd:SDP_CMD_WRSIZEDFULL tag:0x3b9acac1 addr:0xc10000a qospri:0 len:0xf noalloc:0
chn:odat tag:0x3b9acac1 dat:0x3f80 be:0xffffffff
chn:odat tag:0x3b9acac1 dat:0x3f81 be:0xffffffff
chn:odat tag:0x3b9acac1 dat:0x3f82 be:0xffffffff
chn:odat tag:0x3b9acac1 dat:0x3f83 be:0xffffffff
chn:req cmd:SDP_CMD_RDBLKL tag:0x3b9aca25 addr:0x40000d qospri:0 len:0xf noalloc:0
chn:req cmd:SDP_CMD_RDBLKL tag:0x3b9aca31 addr:0x50000e qospri:0 len:0xf noalloc:0
chn:req cmd:SDP_CMD_WRSIZEDFULL tag:0x3b9acacd addr:0xc20000b qospri:0 len:0xf noalloc:0
chn:odat tag:0x3b9acacd dat:0x4f83 be:0xffffffff
chn:odat tag:0x3b9acacd dat:0x9f85 be:0xffffffff
chn:odat tag:0x3b9acacd dat:0x7f88 be:0xffffffff
chn:odat tag:0x3b9acacd dat:0x5f87 be:0xffffffff
Note: Please consider that above file doesn't have any blank lines and also not required in the output files.
########################### Output file1 ##########################
Required output one.txt
chn:req cmd:SDP_CMD_RDBLKL tag:0x3b9aca0d addr:0x20000b qospri:0 len:0xf noalloc:0
chn:req cmd:SDP_CMD_RDBLKL tag:0x3b9aca25 addr:0x40000d qospri:0 len:0xf noalloc:0
chn:req cmd:SDP_CMD_WRSIZEDFULL tag:0x3b9acacd addr:0xc20000b qospri:0 len:0xf noalloc:0
chn:odat tag:0x3b9acacd dat:0x4f83 be:0xffffffff
chn:odat tag:0x3b9acacd dat:0x9f85 be:0xffffffff
chn:odat tag:0x3b9acacd dat:0x7f88 be:0xffffffff
chn:odat tag:0x3b9acacd dat:0x5f87 be:0xffffffff
############################ Output file2 ##########################
Required output zero.txt
chn:req cmd:SDP_CMD_RDBLKL tag:0x3b9aca01 addr:0x10000a qospri:0 len:0xf noalloc:0
chn:req cmd:SDP_CMD_RDBLKL tag:0x3b9aca19 addr:0x30000c qospri:0 len:0xf noalloc:0
chn:req cmd:SDP_CMD_WRSIZEDFULL tag:0x3b9acac1 addr:0xc10000a qospri:0 len:0xf noalloc:0
chn:odat tag:0x3b9acac1 dat:0x3f80 be:0xffffffff
chn:odat tag:0x3b9acac1 dat:0x3f81 be:0xffffffff
chn:odat tag:0x3b9acac1 dat:0x3f82 be:0xffffffff
chn:odat tag:0x3b9acac1 dat:0x3f83 be:0xffffffff
chn:req cmd:SDP_CMD_RDBLKL tag:0x3b9aca31 addr:0x50000e qospri:0 len:0xf noalloc:0
######## Code starts ########
while (my $line1 = <IN_FILE>) { if( ($line1 =~ /addr/) ) { $line1 =~ /addr:([a-z0-9-]+)\s+/; my $address = hex $1; if($address & 1 ) { printf OUT_FILE1 ("$line1"); } else { printf OUT_FILE2 ("$line1"); } } }
######## Code ends ########
I was thinking to use the tag field to print the 4 write data lines just after the write command line since the tag field for write command and write data is unique and constant for every write transaction. RDBLKL = read, WRSIZEDFULL = write. Please ignore the blank lines in the input and output files I provided. I am no able to go to next line with out closing a paragraph in the writeup. Thanks in advance for the help.
In reply to Re^2: Print multiple lines based on condition
by syedasadali95
in thread Print multiple lines based on condition
by syedasadali95
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |