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

  • Home
  • SEARCH
  • 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 7899249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:39:02+00:00 2026-06-03T08:39:02+00:00

I want to be able to compare two text string and display the difference

  • 0

I want to be able to compare two text string and display the difference in color. I tried String::Diff but could not get the difference to display in color. I am using Windows with Active State perl 5, version 12.

Edit : the ansi color etc do not help me with displaying the differences in color
Edit : Here is the result I want

$string1 = "This is string 1" ;
$string2 = "This is string 2" ;

some_diff_cmd($string1,$string2) ;

Output I want (the entries in bold should be in color say red)

### Strings do not match ####

string1 = This is string 1
string2 = This is string 2

  • 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-06-03T08:39:03+00:00Added an answer on June 3, 2026 at 8:39 am

    How about this?

    use Win32::Console::ANSI;
    use String::Diff qw( diff );
    
    my @strings = (
      'This is string 1', 'This is string 2'
    );
    
    my $BOLD_RED_MARK = "\e[1;31m"; # or \e[0;31m, if bold is not required
    my $RESET_MARK    = "\e[0m";
    
    my $diff = String::Diff::diff(@strings,
       remove_open  => $BOLD_RED_SIGN,
       remove_close => $RESET_SIGN,
       append_open  => $BOLD_RED_SIGN,
       append_close => $RESET_SIGN,
    );
    
    print $diff->[0], "\n";
    print $diff->[1], "\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to compare one string to all other strings sequentially
I want to be able to compare two doubles disregarding a possible precision loss.
I want to be able to compare the two following objects for likeness using
I have two instances of System.Text.Encoding. I'd like to be able to compare them
I want to convert two strings to ints to be able to compare them.
I would like to compare two collections (in C#), but I'm not sure of
Say that I have a rather large repository, and I want to compare two
Currently I have two larger vectors of 50+ strings I want to be able
Is there a way to compare two DateTime variables but to disregard the Time
I want to know if I can compare two consecutive jobs in Hadoop. If

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.