<?xml version="1.0" encoding="windows-1252"?>
<node id="995540" title="Need help for extracting Log file using Perl script" created="2012-09-25 08:39:57" updated="2012-09-25 08:39:57">
<type id="115">
perlquestion</type>
<author id="973734">
renjoooz</author>
<data>
<field name="doctext">
&lt;p&gt;
I have 2 log files as given below.Both files have some things in common.I need 1 file having the common items and another file having items which are not common to both.
Thanks in advance.
&lt;/p&gt;


&lt;code&gt;
FILE1:
&lt;CMD&gt; deselectAll
&lt;CMD&gt; uiSetTool ruler
&lt;CMD&gt; uiSetTool select
	dummy_core/pads/dfdtghj_op
	dummy_core/pads/fghf_bg
&lt;CMD&gt; windowSelect 5522.2554.33654.256552.44
&lt;CMD&gt; spaceObject -fixSide bottom -space 0
Spacing instances ...
   selected instances/modules:
dummy_core/pads/xx
dummy_core/pads/hg_2
dummy_core/pads/dhghj_uu
&lt;CMD&gt; deselectAll
&lt;CMD&gt; selectInst core/pads/IO_gnd_right18
&lt;CMD&gt; selectInst core/pads/IO_vdd_right18
&lt;CMD&gt; uiSetTool move5

	dummy_core/pads/gh_5
	dummycore/pads/ghjk_0
	dummy_core/pads/ghjk_8


FILE2:
1.	this file is for error checking
2.	this file is for error checking
dummy_core/pads/dfdtghj_op
dummy_core/pads/fghf_bg
dummy_core/pads/xx
dummy_core/pads/hg_2
&lt;CMD&gt; utTl ruler
&lt;CMD&gt; utTl select
dummy_core/pads/dhghj_uu
dummy_core/pads/gh_5
dummycore/pads/ghjk_0
pads/fghf_bg
pads/dhghj_u
dummy_core/pads/ghjk_8


RESULT NOTCOMMON:
&lt;CMD&gt; deselectAll
&lt;CMD&gt; uiSetTool ruler
&lt;CMD&gt; uiSetTool select
&lt;CMD&gt; windowSelect 5522.2554.33654.256552.44
&lt;CMD&gt; spaceObject -fixSide bottom -space 0
Spacing instances ...
   selected instances/modules:
&lt;CMD&gt; deselectAll
&lt;CMD&gt; selectInst core/pads/IO_gnd_right18
&lt;CMD&gt; selectInst core/pads/IO_vdd_right18
&lt;CMD&gt; uiSetTool move5
1.	this file is for error checking
2.	this file is for error checking
&lt;CMD&gt; utTl ruler
&lt;CMD&gt; utTl select
pads/fghf_bg
pads/dhghj_u


RESULT COMMON:
dummy_core/pads/dfdtghj_op
dummy_core/pads/fghf_bg
dummy_core/pads/xx
dummy_core/pads/hg_2
dummy_core/pads/dhghj_uu
dummy_core/pads/gh_5
dummycore/pads/ghjk_0
dummy_core/pads/ghjk_8
&lt;/code&gt;

&lt;p&gt;
I have tried different ways to get the result...but none of them was successful...
I am providing some of the codes i have tried
&lt;/p&gt;

&lt;code&gt;
#!/usr/bin/perl
$fnx = "/home/perl/t1x.g";
$fny = "/home/perl/t25y.g";
$fnz = "/home/perl/t22z.g";
$fntmp = "/home/perl/t22tmp.g";
open FPX, "$fnx" or die "Error in write:$!";
open FPY, "$fny" or die "Error in write:$!";
open FPZ, "&gt;$fnz" or die "Error in write:$!";
open FPTMP, "&gt;$fntmp" or die "Error in write:$!";
while (&lt;FPX&gt;) {
@x_line = $_;
while (&lt;FPY&gt;) {
if($_ == @x_line){
print "Saving matched at $.\n";
print FPTMP "$_ \n";

}
else{
print "Saving unmatched at $.\n";
print FPZ "$_ \n";
}
}
}
close FPX;
close FPY;
close FPZ;


#!/usr/bin/perl
$fnx = "/home/perl/t1x.g";
$fny = "/home/perl/t25y.g";
$fnz = "/home/perl/t22z.g";
$fntmp = "/home/perl/t22tmp.g";
open FPX, "$fnx" or die "Error in write:$!";
open FPZ, "&gt;$fnz" or die "Error in write:$!";
open FPTMP, "&gt;$fntmp" or die "Error in write:$!";
XFILE: $flag = 0;
while ($x_line = &lt;FPX&gt;) {
	open FPY, "$fny" or die "Error in write:$!";
	while ($y_line = &lt;FPY&gt;) {
	if($y_line eq $x_line) {
	print "Match found at $y_line\n";
	print FPTMP "$y_line\n";
	$flag = 1; 
	next XFILE;
	}
	else	{
	print "Match not found at $.\n";
	next;
	}
	}
if ($flag == 0) {
print "Some Match not found at $x_line\n";
print FPZ "$x_line\n";
}
close FPY;
}
close FPX;
close FPZ;
close FPTMP;


#!/usr/bin/perl
$fnx = "/home/perl/t1x.g";
$fny = "/home/perl/t25y.g";
$fnz = "/home/perl/t22z.g";
$fntmp = "/home/perl/t22tmp.g";
open FPX, "$fnx" or die "Error in write:$!";
open FPY, "$fny" or die "Error in write:$!";
open FPZ, "&gt;$fnz" or die "Error in write:$!";
open FPTMP, "&gt;$fntmp" or die "Error in write:$!";
while (&lt;FPX&gt;) {
@x_line = $_;
while (&lt;FPY&gt;) {
if($_ =~ m/@x_line/){
@bb = m/@x_line/;
print FPTMP "@bb\n";
next;
}
else {
print FPZ "@x_line";
next;
}
}
}
close FPX;
close FPY;
close FPZ;


#!/usr/bin/perl
$fnx = "/home/t1x.g";
$fny = "/home/t25y.g";
$fnz = "/home/t22z.g";
$fntmp = "/home/t22tmp.g";
open FPX, "$fnx" or die "couldn't open $fnx: $!";
open FPZ, "&gt;$fnz" or die "couldn't open $fnz: $!";
open FPTMP, "&gt;$fntmp" or die "couldn't open $fntmp: $!";
XFILE:while (@x_line = &lt;FPX&gt;) {
	open FPY, "$fny" or die "Error in write:$!";
	while (@y_line = &lt;FPY&gt;) {
    	if (@x_line eq @y_line){
	print FPTMP "@x_line\n";
	goto XFILE;
	}
	else{
	print FPZ "@y_line\n";
	}
	}
close FPY;
}
close FPX;
close FPZ;
close FPTMP;
&lt;/code&gt;</field>
</data>
</node>
