I have the following script below in where I read in certain elements in a XML file and write them to a text file. What I need to do is before I write to the file is to compare the records in the text file to the XML elements read in. If any of the records in the file matches the XML elements, then don't write it out to the text file...
Copy of the text file:
Thursday, November 01, 2007|5:07am|8:45am|4:55am
Friday, November 02, 2007|1:50am|3:25am|1:50am
Monday, November 05, 2007|4:29am|5:47am|4:38am
Tuesday, November 06, 2007|6:41am|8:05am|6:44am
Wednesday, November 07, 2007|4:13am|5:42am|4:22am
Thursday, November 08, 2007|4:08am|5:36am|4:53am
Friday, November 09, 2007|2:09am|3:29am|Not yet complete
Monday, November 12, 2007|6:51am|run|7:16am
Tuesday, November 13, 2007|4:18am|5:28am|4:54am
Wednesday, November 14, 2007|4:27am|5:57am|4:16am
Thursday, November 15, 2007|6:34am|Running;|6:35am
thanks
Copy of the text file:
Thursday, November 01, 2007|5:07am|8:45am|4:55am
Friday, November 02, 2007|1:50am|3:25am|1:50am
Monday, November 05, 2007|4:29am|5:47am|4:38am
Tuesday, November 06, 2007|6:41am|8:05am|6:44am
Wednesday, November 07, 2007|4:13am|5:42am|4:22am
Thursday, November 08, 2007|4:08am|5:36am|4:53am
Friday, November 09, 2007|2:09am|3:29am|Not yet complete
Monday, November 12, 2007|6:51am|run|7:16am
Tuesday, November 13, 2007|4:18am|5:28am|4:54am
Wednesday, November 14, 2007|4:27am|5:57am|4:16am
Thursday, November 15, 2007|6:34am|Running;|6:35am
Code:
#!/opt/perl/bin/perl
use XML::Simple;
my $InputFile = "/Automation/MSR_XML_HTML/Previous.xml";
my $OutputFile = "/data/EBIS_Output.txt";
open (IN, "$InputFile") or die "$InputFile $!";
open (OUT, ">>$OutputFile") or die "$OutputFile $!";
my $ref = XMLin($InputFile);
print OUT (@{$ref->{Info}}{qw(TODAY)}),'|', join('|',map/(\S+)/,@{$ref->{Info}}{qw(TNC RPI CMHM)}),"\n";
close IN;
close OUT;
thanks