Have a list of field names in an array.
fld1, fld2, fld3, fldn..
These correspond to Field values in a text string.
I am trying to compare two files to see what field has
changed and return those values.
eg. fld1: changed from v1 to v2.
ex. file
Event ID<~>Container Number<~>Batch Number<~>Batch Type
0100<~>IDRFtest<~>RTR0100<~>RTR
0101<~>IDRFtest<~>RTR0101<~>RTR
0102<~>IDRFtest<~>RTR0102<~>RTR
Not being a perl expert yet, here is what I have so far...
#!/usr/local/bin/perl -w
print "Please input ldap file: ";
chomp ($FILE_LDAP = <STDIN>);
print "Please input sig file: ";
chomp ($FILE_SIG = <STDIN>);
$FIELD_LIST_CMP1 = `grep "Event ID" $FILE_LDAP`;
$FIELD_LIST_CMP2 = `grep "Event ID" $FILE_SIG`;
if ($FIELD_LIST_CMP1 ne $FIELD_LIST_CMP2) {
print "List of fields do not match\!\n";
exit;
}
$FIELD_LIST = `grep "Event ID" $FILE_LDAP`;
chomp $FIELD_LIST;
push @FIELD_LIST, split ("<~>",$FIELD_LIST);
@COMM = split /\n/,`comm -3 $FILE_LDAP $FILE_SIG`;
&Check_EV;
&Check_Text;
sub Check_EV {
# Check for <~> in the line.
@FIELD_DIFF = grep /<~>/, @COMM;
# This gets list of Event ID's
for (@FIELD_DIFF) {
# unix comm command seperates differences in columns
if (!/^\s/) {
@var = (split /<~>/, $_);
push @EV_LIST, $var[0];
}
}
}
---------------------
sub Check_EV is where I need some help. Feel free to change anything..
I know there is a super hootie way of doing this. Please help.
Brandon Cole
bcole23@hotmail.com
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.