Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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.

FILE1: <CMD> deselectAll <CMD> uiSetTool ruler <CMD> uiSetTool select dummy_core/pads/dfdtghj_op dummy_core/pads/fghf_bg <CMD> windowSelect 5522.2554.33654.256552.44 <CMD> spaceObject -fixSide bottom -space 0 Spacing instances ... selected instances/modules: dummy_core/pads/xx dummy_core/pads/hg_2 dummy_core/pads/dhghj_uu <CMD> deselectAll <CMD> selectInst core/pads/IO_gnd_right18 <CMD> selectInst core/pads/IO_vdd_right18 <CMD> 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 <CMD> utTl ruler <CMD> 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: <CMD> deselectAll <CMD> uiSetTool ruler <CMD> uiSetTool select <CMD> windowSelect 5522.2554.33654.256552.44 <CMD> spaceObject -fixSide bottom -space 0 Spacing instances ... selected instances/modules: <CMD> deselectAll <CMD> selectInst core/pads/IO_gnd_right18 <CMD> selectInst core/pads/IO_vdd_right18 <CMD> uiSetTool move5 1. this file is for error checking 2. this file is for error checking <CMD> utTl ruler <CMD> 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

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

#!/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, ">$fnz" or die "Error in write:$!"; open FPTMP, ">$fntmp" or die "Error in write:$!"; while (<FPX>) { @x_line = $_; while (<FPY>) { 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, ">$fnz" or die "Error in write:$!"; open FPTMP, ">$fntmp" or die "Error in write:$!"; XFILE: $flag = 0; while ($x_line = <FPX>) { open FPY, "$fny" or die "Error in write:$!"; while ($y_line = <FPY>) { 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, ">$fnz" or die "Error in write:$!"; open FPTMP, ">$fntmp" or die "Error in write:$!"; while (<FPX>) { @x_line = $_; while (<FPY>) { 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, ">$fnz" or die "couldn't open $fnz: $!"; open FPTMP, ">$fntmp" or die "couldn't open $fntmp: $!"; XFILE:while (@x_line = <FPX>) { open FPY, "$fny" or die "Error in write:$!"; while (@y_line = <FPY>) { 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;

In reply to Need help for extracting Log file using Perl script by renjoooz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (8)
    As of 2014-11-27 16:15 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (186 votes), past polls