Hi pc88mxer,
Actually my goal is to take some data from brd_sym_pn.txt file. Specifically the $RefDes, $Pnum and $Pkg_Type.
Then check that the "$Pnum and $Pkg_Type" for each "$RefDes" matches the assigned "$LogPnum" and "$LogPkg_Type" from sym_text_latest.txt.
If a match is found it reports back whether the reference designator is using the correct $Pnum and $Pkg_Type.
I have purpously have made some $Pkg_Type incorrect to check my script.
#This program will return the refdes, part number and package type #tab delimeted for each instance from brd_sym_pn.txt (extracted from #a layout database) and part number and package type from sym_tezt_lat +est.txt #generated from sym_text_mmddyy.xls when part number is entered at <ST +DIN> prompt #Compares the pkg_type used on board with sym_text log files and repor +ts #whether the pkg_type is correct or reports what the correct pkg_type +should be. $Pnum = "12-0259-01"; print $Pnum; open(partlog, "sym_text_latest.txt") || die("failed to open sym_ +text_latest.txt"); while($line = <partlog>) { @fields = split(/\t/,$line); if($fields[0] eq $Pnum) { our $LogPnPkg = "$fields[0]\t$fields[4]"; our $LogPnum = "$fields[0]"; our $LogPkg_Type = "$fields[4]"; } } open(brdpartlog, "brd_sym_pn.txt") || die("failed to open brd_s +ym_pn.txt"); print "\n"; open(brdpartlog, "brd_sym_pn.txt") || die("failed to open br +d_sym_pn.txt"); print "\n"; while($line = <brdpartlog>) { @fields = split(/\t/,$line); if($fields[1] eq $Pnum) { our $RdesPnPkg = "$fields[0]\t$fields[1]\t$fields[2] +"; our $BrdPnPkg = "$fields[1]\t$fields[2]"; our $RefDes = "$fields[0]"; if($BrdPnPkg eq $LogPnPkg) { print("$RefDes\t$BrdPnPkg is the correct Allegro footp +rint.\n"); } else { print("$RefDes\t$BrdPnPkg should be using $LogPkg_Type +\n"); } } }
prints results:
J2 12-0259-01 HDR-1X28-100-FLK-VT should be using HDR-1X2-100-FLK-VT
J1 12-0259-01 HDR-1X2-100-FLK-VT is the correct Allegro footprint.

In reply to Re^2: compare data between two files using Perl by steveb94553
in thread compare data between two files using Perl by steveb94553

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.