I have a perl code to compare 2 strings
First string I get from parsing a URL content (say $version and its value is CVP-LATEST-5.3.4.iso)
Another string I open a local file (info.txt) and read it. The file has only 1 string (say $oldversion and its value is CVP-LATEST-5.3.4.iso)
I get these both strings into $version and $oldversion
after that I do
if ($version ne $oldversion)
{
print "Im doing something here\n");
unlink(info.txt);
open file info.txt
print $version to into.txt
close info.txt
}
else
{
print "ERROR\n");
}
Here you can see if $version and $oldversion match it will print ERROR.
Everything works fine until:
When I open the file info.txt and manually edit (I will press backspace and then will type the same charectores again) and then save and exit.
Even now $version and $oldversion should have the same content, because I pressed backspace and later entered the same deleted charector.
Now when I run the script I can see the IF loop is going TRUE instead of FALSE.
Since the contents are same the IF should go FALSE, But its going true.
I have no idea what is happening. I tried printing $version and $oldversion before and after the IF statement, it prints same exact same values, but IF is going TRUE.
I read the file content as folows.
my $oldversion = <FILE>;
You can try this: