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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:59:46+00:00 2026-06-12T15:59:46+00:00

I want to use binmode on binary files in Perl. So how can I

  • 0

I want to use binmode on binary files in Perl. So how can I know the file at hand is binary or text?

That means first I’d read full file to know if it is in binary or text then rewind the FP with binmode set if it is binary.

Since Perl -B/-T checks only a beginning block of text, it usually classifies pdf as text file(the source code could be hiding in any extension like .gif,.pdf etc). So I’d need to read full file data to decide if it is binary or text file.

I’ve heard that any source code file( .pl,.c,.php etc) will not contain invisible characters like 0x0-0x1f and 0xff onwards.

Can I check every byte to be in this range to declare whether or not it is a source code file?

  • 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-12T15:59:47+00:00Added an answer on June 12, 2026 at 3:59 pm

    Do you really need to read the file in text mode if it’s a text file? You could use binmode unconditionally.

    If you have a piece of code that deal with text files, it can filter out any extraneous carriage returns (0D). If you don’t have a such a piece of code, then it surely doesn’t matter if the carriage returns are left in.

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

Sidebar

Related Questions

I want use $.ajax to read some infomation from xml file,here is my js
I need to byte-shift a text file. I know absolutely nothing about perl, but
I want use BYTE_ORDER macro in my Xcode project but i can't because i
I want use a single php file to handle all of my voting requests.
I want use jQuery in my project. I know the javascript_include_tag calls the jQuery
I want use a typedef struct that isn't already defined, but it is later.
I want use Kendo ui window, but I can't see what the problem is.
i want to use title on text. is this possible to make title on
I want use many bitmap for my game canvas. I can't Recycle bitmaps, because
I want use 1000 separator(,) for numeric values. how can i format strings 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.