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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:55:58+00:00 2026-05-22T19:55:58+00:00

I have a few lines of text that I’m trying to use Perl’s split

  • 0

I have a few lines of text that I’m trying to use Perl’s split function to convert into an array. The problem is that I’m getting some unusual extra characters in the output, specifically the following string “\cM” (without the quotes). This string appears where there were line breaks in the original text; however, (I believe) those line breaks were removed in the text that I’m trying to split. Does anybody know what’s going on with this phenomenon? I posted an example below. Thanks.

Here’s the original plain text that I’m trying to split. I’m loading it from a file, in case that matters:

10b2obo12b2o2b$6b3obob3o8bob3o2b$2bobo10bo3b2obo4bo2b$2o4b2o5bo3b4obo
3b2o2b$2bob2o2bo4b3obo5b4obob$8bo4bo13b3o$2bob2o2bo4b3obo5b4obob$2o4b
2o5bo3b4obo3b2o2b$2bobo10bo3b2obo4bo2b$6b3obob3o8bob3o2b$10b2obo12b2o!

Here is my Perl code that is supposed to do the splitting:

while(<$FH>) {
    chomp;
    $string .= $_;
    last if m/!$/;
}

@rows = split(qr/\$/, $string);
print;          # a dummy line to provide a breakpoint for the debugger

This what the debugger outputs when it gets to the “print” line. The issue I’m trying to deal with appears in lines 3, 7, and 10:

DB<10> p $string
2o5bo3b4obo3b2o2b$2bobo10bo3b2obo4bo2b$6b3obob3o8bob3o2b$10b2obo12b2o!
DB<11> x @rows
0  '10b2obo12b2o2b'
1  '6b3obob3o8bob3o2b'
2  '2bobo10bo3b2obo4bo2b'
3  "2o4b2o5bo3b4obo\cM3b2o2b"
4  '2bob2o2bo4b3obo5b4obob'
5  '8bo4bo13b3o'
6  '2bob2o2bo4b3obo5b4obob'
7  "2o4b\cM2o5bo3b4obo3b2o2b"
8  '2bobo10bo3b2obo4bo2b'
9  '6b3obob3o8bob3o2b'
10  "10b2obo12b2o!\cM"
  • 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-22T19:55:59+00:00Added an answer on May 22, 2026 at 7:55 pm

    You know, changing the file input separator would make this code a lot simpler.

    $/ = '$';
    
    my @rows = <$FH>;
    chomp @rows;
    
    print "@rows";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few lines of PowerShell code that I would like to use
I have few lines of text in TextView. I want to apply italics to
I have a few links that should all open in the same window or
I have a few places where I use the line below to clear out
I have a few Visual Studio Solutions/Projects that are being worked on in my
I have an ASP page that retrieves text from a database but the formatting
Let's say I have an input text field and a few anchor links. The
How do I create subdomains in ASP.NET? I have few links on my homepage(Home.aspx)
I have few asynchronous tasks running and I need to wait until at least
I have few different applications among which I'd like to share a C# enum.

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.