parsing the text file

July 11, 2011 at 02:54:54
Specs: Windows XP
hi, can anyone let me know how to do this task in perl:

INPUT FILE output file
A,1,B A,1,B
A,2,D after parsing B,1_1,A
B,1,C -------------------> A,2,D
B,1_1,A D,2_2,A
D,2_2,A B,1,C
C,1_1,B C,1_1,B


WHEN AN INPUT FILE IS BEING PARSED THE REQUIRED OUTPUT SHOULD BE AS SHOWN ABOVE, can anyone let me know how to deal with it?

thanks in advance for the time and trouble taken


See More: parsing the text file

Report •

#1
August 30, 2011 at 18:15:18

use strict;

open FILE, "/dir/file.txt";
open OUTPUT, ">>/dir/output.txt";

foreach my $line (<FILE>){
    $line =~ s/^A\,2\,D/B\,1_1\,A/);
   print OUTPUT $line;
 
}

close FILE;
close OUTPUT;

try that its untested so it should give you a basic idea


Report •
Related Solutions


Ask Question