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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:42:02+00:00 2026-06-18T13:42:02+00:00

I want to read an input file line by line, but this file has

  • 0

I want to read an input file line by line, but this file has unknown ending character.

Editor vim does not know it either, it represents this character as ^A and immediately starts with characters from new line. The same is for perl. It tried to load all lines in once, because it ignores these strange end of line character.

How can I set this character as end of line for perl? I don’t want to use any special module for it (because of our strict system), I just want to define the character (maybe in hex code) of end of line.

The another option is to convert the file to another one, with good end of line character (replace them). Can I make it in some easy way (something like sed on input file)? But everything need to be done in perl.

It is possible?

Now, my reading part looks like:

open (IN, $in_file);
$event=<IN>;   # read one line
  • 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-18T13:42:03+00:00Added an answer on June 18, 2026 at 1:42 pm

    The ^A character you mention is the “start of heading” character. You can set the special Perl variable $/ to this character. Although, if you want your code to be readable and editable by the guy who comes after you (and uses another editor), I would do something like this:

    use English;
    
    local $INPUT_RECORD_SEPARATOR = "\cA" # 'start of heading' character
    
    while (<>)
    {
        chomp; # remove the unwanted 'start of heading' character
        print $_ . "\n";
    }
    

    From Perldoc:

    $INPUT_RECORD_SEPARATOR
    $/

    The input record separator, newline by default. This influences Perl’s idea of what a “line” is.

    More on special character escaping on PerlMonks.

    Oh and if you want, you can enter the “start of heading” character in VI, in insert mode, by pressing CTRL+V, then CTRL+A.

    edit: added local per Drt’s suggestion

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

Sidebar

Related Questions

I want to read line-by-line from a given input file,, process each line (i.e.
I want to write a batch file to read an input text file, extract
I want to read the file path from html input type=file (the entry selected
Hi I can't understand this error I want read this XML file: <?xml version=1.0
I have a text file. I want read that file. But In that if
I want to read a file line by line and capture one particular line
I wrong a function to read a configuration file, but if the command line
I'm trying to read file line by line in bash. Every line has format
I want to read user input from STDIN and process the preliminary input while
I want to read a INI file from python, and I came up with

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.