Spawning another copy of Perl to handle a search and replace feels completely wrong. Since your files are "in sync" you can simply read them in parallel and generate the output as you go. The following code uses a trick described in I know what I mean. Why don't you? to make a self contained example. You should replace the open statements for production code.
#!/usr/bin/perl use strict; use warnings; my $File1 = <<FILE; WL,BL,Die1 WL0,BL0,1708 WL0,BL1,1708 WL0,BL2,1708 WL0,BL3,1931 WL0,BL4,1931 FILE my $File2 = <<FILE; WL,BL,Die 2 WL0,BL0,1708 WL0,BL1,1931 WL0,BL2,1708 WL0,BL3,1931 WL0,BL3,1708 FILE open my $in1, '<', \$File1; open my $in2, '<', \$File2; while (my $line1 = <$in1>) { chomp $line1; defined (my $line2 = <$in2>) or last; print $line1, ',', (split ',', $line2)[-1]; }
Prints:
WL,BL,Die1,Die 2 WL0,BL0,1708,1708 WL0,BL1,1708,1931 WL0,BL2,1708,1708 WL0,BL3,1931,1931 WL0,BL4,1931,1708
In reply to Re: Solve the large file size issue
by GrandFather
in thread Solve the large file size issue
by Vkhaw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |