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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:11:10+00:00 2026-05-26T15:11:10+00:00

there: I’m new to Perl, and get a string concatenation problem of it. I

  • 0

there:
I’m new to Perl, and get a string concatenation problem of it. I have two strings below:

my $string1 = "hello\U\Q \t\n\f\b\aWorld" . "\n" . "\E";
my $string2 = "hello\U\Q \t\n\f\b\aWorld\n\E";

They are looked the same to me, until i print them out.
$string1 looks like this:

hello\ \    \
\
 \WORLD

and with a bell ring.

$string2 is this one:

hello\ \    \
\
 \WORLD\

with the same bell ring, and a backslash at the tail.

Why does $string2 get a backslash at its end but $string1 doesn’t?

  • 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-26T15:11:11+00:00Added an answer on May 26, 2026 at 3:11 pm

    When you use \Q you’re telling it to quote (put a backslash in front of) all the characters that aren’t matched by \w. The result is that you’re getting a backslash added every time there’s a backslash in your code. e.g. \a creates the bell sound but your string gets a backslash added in. When you use \Q it behaves this way until you reach \E or get to the end of the string.

    When you create $string1 you actually have 3 separate strings that you’re adding together so they’re evaluated separately. The result is that only the first of the 3 is affected by the \Q.

    In the second example the \n\E results in \\ in the string. When you print this out it results in the trailing backslash you’re seeing.

    Hope that makes sense.

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

Sidebar

Related Questions

There was some progress made to the earlier problem. Now there is a new
There are two intents on the receiver side which are called from the same
There are two table s : one is the master and one the detail
There are many string matching algorithms can be used to find a pattern (string)
There is this strange situation I'm fighting on. I have 3 pages, les call
There have been multiple questions regarding this topic but I have never really settled
There are two major fix engines: opensource QuickFix http://www.quickfixengine.org/ commercial Fix Antenna http://www.b2bits.com/trading_solutions/fix_engines/fix_engine_cpp.html What
There seems to be only one way to get media to autoplay in iOS
There are two weird operators in C#: the true operator the false operator If
There are two popular closure styles in javascript. The first I call anonymous constructor

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.