Hi all;
Pretty green to perl programming; been searching high and low for a perl (preferably) or unix script that will compare 2 CSV strings in the same file that are separated buy the "|" character (so basically they're side by side) and give the results of ONLY the exact change; note that 19 is not a line number it's just a numeric field. If it helps; we can assume that both CSV strings have fields so we can call them:
rule, client, location, script, destination, enabled, search, compress
Also; rule can never be altered\changed only fields 2 to 8 can be modified.
So with all that here's an exmple; if I have a file (call it file1) with this content:
19,gmp,charlie,brown,is,funny,<super>man<isalive> <super>boy<isolder> <wonderwoman>is<cute>,YES|19,gmp,charlie,brown,is,funny,<super>man<isalive> <super>boy<isolder>,YES
300,gjv,mary,hadalittlelamb,its,flease,<was>whaite<assnow> <and>everywhere<that> <mary went>thelambwas<sure to go>,YES|300,gjv,mary,hadalittlelamb,its,flease,<was>white<assnow> <and>everywhere<that> <marywent>thelambwas<suretogo> <thefarmer>inthe<dell> <hewas>neverto<comeout>,YES
3012,gjv,timmy,wasabad,boy,andhe,<was>always<causing> <trouble>around<town> <untilone>day<hewenttoofar>,YES|3012,gjv,timmy,wasabad,boy,andhe,<was>always<causing> <trouble>around<town> <hewas>caught<andsentaway>,YES
Output I am looking for (to be written to file2):
-------------------------------------
AUDIT REPORT
CHANGED:
field1:19
BEFORE:
19,gmp,charlie,brown,is,funny,<super>man<isalive> <super>boy<isolder> <wonderwoman>is<cute>,YES
AFTER:
19,gmp,charlie,brown,is,funny,<super>man<isalive> <super>boy<isolder>,YES
SPECIFICS:
<wonderwoman>is<cute> ----> removed
CHANGED:
field1:300
BEFORE:
300,gjv,mary,hadalittlelamb,its,flease,<was>whaite<assnow> <and>everywhere<that> <mary went>thelambwas<sure to go>,YES
AFTER:
300,gjv,mary,hadalittlelamb,its,flease,<was>white<assnow> <and>everywhere<that> <marywent>thelambwas<suretogo> <thefarmer>inthe<dell> <hewas>neverto<comeout>,YES
SPECIFICS:
<thefarmer>inthe<dell> ----> added
<hewas>neverto<comeout> ----> added
CHANGED:
field1:3012
BEFORE:
3012,gjv,timmy,wasabad,boy,andhe,<was>always<causing> <trouble>around<town> <untilone>day<hewenttoofar>,YES
AFTER:
3012,gjv,timmy,wasabad,boy,andhe,<was>always<causing> <trouble>around<town> <hewas>caught<andsentaway>,YES
SPECIFICS:
<untilone>day<hewenttoofar> ----> removed
<hewas>caught<andsentaway> ----> added
SUMMARY
Rule was changed for 2 clients: gmp,gjv
Total number of rules changes: 3
Rules changed:
gmp: 19
gjv: 300,3012
--------------------------------------------------------
Notes: notice on the SUMMARY that even though there were 2 records changed for client gjv that it only appears once in the line "Rule was changed for 2 clients:" but it is accouhted for in the line "Total number of rules changes:"
Thanks
G