Richard Kreidl
asked on
String comparison not working???
I'm trying to do a string comparison with the Perl Script below, but it's not working for some reason???
Basically I checking to see if string from the XML element: TODAY in the Previous.xml file is in the Output.txt file. If it is don't write to the text file otherwise write to the file.
Previous.xml file
<?xml version="1.0" standalone="yes"?>
<MSR>
<Info>
<TODAY>Tuesday, November 20, 2007</TODAY>
<numAutoSys>176</numAutoSy s>
<numMVS>35</numMVS>
</Info>
</MSR>
Text file:
Thursday, November 01, 2007|5:07am|8:45am|4:55am
Friday, November 02, 2007|1:50am|3:25am|1:50am
Friday, November 16, 2007|2:38am|4:24am|3:02am
Monday, November 19, 2007|Running;|Bypassed;|No t
Tuesday, November 20, 2007|4:57am|6:26am|4:55am
So, with the status of the files above it shouldn't write to the text file because the date from the XML element: TODAY which is "Tuesday, November 20, 2007" is already in the text file as you can see...
thanks
Basically I checking to see if string from the XML element: TODAY in the Previous.xml file is in the Output.txt file. If it is don't write to the text file otherwise write to the file.
Previous.xml file
<?xml version="1.0" standalone="yes"?>
<MSR>
<Info>
<TODAY>Tuesday, November 20, 2007</TODAY>
<numAutoSys>176</numAutoSy
<numMVS>35</numMVS>
</Info>
</MSR>
Text file:
Thursday, November 01, 2007|5:07am|8:45am|4:55am
Friday, November 02, 2007|1:50am|3:25am|1:50am
Friday, November 16, 2007|2:38am|4:24am|3:02am
Monday, November 19, 2007|Running;|Bypassed;|No
Tuesday, November 20, 2007|4:57am|6:26am|4:55am
So, with the status of the files above it shouldn't write to the text file because the date from the XML element: TODAY which is "Tuesday, November 20, 2007" is already in the text file as you can see...
thanks
#!/opt/perl/bin/perl
use XML::Simple;
my $InputFile = "/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);
my $string = @{$ref->{Info}}{qw(TODAY)};
print $string;
while(<IN>) {
$content=$_;
}
if ($content =~ /$string/ig)
{
close IN;
close OUT;
exit(0);
} else {
print OUT (@{$ref->{Info}}{qw(TODAY)}),'|', join('|',map/(\S+)/,@{$ref->{Info}}{qw(TNC RPI CMHM)}),"\n";
}
close IN;
close OUT;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Help with the coding please???
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
while(<IN>) {
to this:
while(<OUT>) {
It still doens't work...