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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:05:41+00:00 2026-06-13T15:05:41+00:00

Why are the two printed numbers different? #!/usr/bin/env perl use warnings; use 5.10.1; my

  • 0

Why are the two printed numbers different?

#!/usr/bin/env perl
use warnings;
use 5.10.1;

my $sep = '';
my $number = 110110110110111;

$number =~ s/(\d)(?=(?:\d{3})+\b)/$1$sep/g;
say "A: <$number>";

$number =~ s/\Q$sep\E//g;
say "B: <$number>";

Output:

A: <110110110110111>
B: <11111111111>
  • 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-13T15:05:42+00:00Added an answer on June 13, 2026 at 3:05 pm

    Quote from man perlop:

    If the pattern evaluates to the empty string, the last successfully
    executed regular expression is used instead.

    Try to insert one successful regex match before the second substitution to see what’s going on:

    (my $foo = '1') =~ s/1/x/; # successfully match “1”
    $number =~ s///g;          # now you’re deleting all 1s
    say "B: <$number>";        # <0000>
    

    I’d say this should be deprecated and warned about by use warnings. It’s hard to see the benefits.

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

Sidebar

Related Questions

I have two input fields, where people can write numbers. And what I need
I want to calculate , in two lists (same lenght), the number of elements
I have two programs written in C++ that use Winsock. They both accept TCP
Two trees are said to be identical if they contain same set of elements
Two questions only: I have a website including a section of Blog in wordpress.
Two days ago I spontaneously bought myself a domain. The day before that, I
Two related questions. First: does this repro for you or is it something local
Two tables. I have column a (datetime type) and column b (numeric type) in
Two (subclasses of) panels, a CanvasSubPanel (which draws a matplotlib figure) and UnderPanel are
Two general questions I'm wondering about both in the case for a given file(.js,

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.