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 6817397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:02:59+00:00 2026-05-26T21:02:59+00:00

I have the below script from a user. When ran on perl 5.8.4 and

  • 0

I have the below script from a user. When ran on perl 5.8.4 and 5.12.4, it prints 1, but not in 5.10.0 (prints 0).

perl  -e ' my $a=0; my $net="<*2>ColBnk<2"; if (($net =~ s/([(<])/$1/g) != ($net =~ s/([>)])/$1/g)){$a++} print $a;'

Is this the problem with the code (comparing string variable with != instead of ne or could this be due to missing semicolon after $a++).
I tried to debug it by printing the value of ($net =~ s/([(<])/$1/g) and ($net =~ s/([>)])/$1/g) and both are printing the same value. Please refer the below code

use strict;
use warnings; 


#/mu/bin/perl  -e '
 my $a=0; 
 my $net="<*2>ColBnk<2"; 

 my $test="<*2>ColBnk<2"; 
 $test =~ s/([(<])/$1/g;
 print "\n$test" ;
 $test =~ s/([>)])/$1/g;
 print "\n$test" ;

 if (($net =~ s/([(<])/$1/g) ne ($net =~ s/([>)])/$1/g)){$a++;} 

 print "\n Value of a =$a";

 #'

Could you please provide any pointers.
Thanks for your help,
Ashish

  • 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-26T21:03:00+00:00Added an answer on May 26, 2026 at 9:03 pm

    I can confirm that it works in 5.8.9 and 5.14.2, but does not work in 5.10.0. It must be a bug introduced somewhere between 5.8 and 5.10, and subsequently fixed. I used Porting/bisect.pl to find out where it broke. It was this commit, which was introduced in Perl 5.9.4. It was then fixed by this commit, which was introduced in Perl 5.10.1.

    When I tried using bisect.pl, I kept getting an error about needing to have a C compiler (even though I do have one installed). It turns out that bisect.pl doesn’t use the normal compiler detection of Perl’s Configure script (presumably to save time). If the default doesn’t work, you need to use the -D option of bisect.pl to set it. (e.g., I used -D{cc,ld}=/usr/bin/gcc).

    You can find the exact change that introduced the bug by performing the following steps:

    $ git clone git://perl5.git.perl.org/perl.git
    $ mkdir perl-bisect
    $ cd perl
    $ cp -a Porting/bisect* ../perl-bisect/
    $ ../perl-bisect/bisect.pl --target=miniperl --end=v5.10.0 --start=perl-5.8.4 \
      -e 'my $a=0; my $net="<*2>ColBnk<2"; if (($net =~ s/([(<])/$1/g) != ($net =~ s/([>)])/$1/g)){$a++} die unless $a;'
    

    If you must use Perl 5.10.0, then you can work around the bug by storing the result of each s///g into a temporary variable, and then comparing the two variables:

    perl -e 'my $a=0; my $net="<*2>ColBnk<2"; my $x = ($net =~ s/([(<])/$1/g); my $y = ($net =~ s/([>)])/$1/g); if ($x != $y){$a++} print $a;'
    

    But a better solution is to upgrade to a fixed version. Perl 5.10 is officially end-of-life, but you could install 5.10.1 anyway if you don’t want to make a large change. Or you can upgrade to 5.12 or 5.14.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about Perl from the script below. If the input for
I have a ruby script below which infinitely prints numbers from 1 onward. How
I have tested the below script on a demo page which is not using
I have a Perl script which nests foreach loops as seen below. It takes
I have a user who randomly gets a Script Error box (shown below) which
I have a dropdownlist (asp.net) and when user change the selection from the dropdownlist
I have a perl script which is used to process some data files from
For some reason the script below is not working. This is the code I
Alrighty so below I have this script doing exactly what I want; I'm using
I have a script below which reads on displayed information from my mysql database

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.