Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6225809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:54:45+00:00 2026-05-24T08:54:45+00:00

I have a perl code to compare 2 strings First string I get from

  • 0

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>;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:54:46+00:00Added an answer on May 24, 2026 at 8:54 am

    You can try this:

    my $oldversion = <FILE>;
    chomp($oldversion);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Perl code which relies on Term::ReadKey to get the terminal width. My
I have some Perl code (for performance analysis) first developed under Linux which now
I have this legacy code base (Compaq PERL) , about 1500 lines of code,
I have Perl on Mac, Windows and Ubuntu. How can I tell from within
I have a perl variable $results that gets returned from a service. The value
Perl is really good for writing the kind of string/file parsing programs that I
I have some perl code which establishes a signal handler: $SIG{'KILL'} = sub {
I have a piece of Perl code for searchnig a directory and display the
I have tried using the following Perl code, but the worksheet does not copy
Suppose I have a piece of Perl code like: foreach my $x (@x) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.