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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:29:30+00:00 2026-06-08T06:29:30+00:00

I have to read a big (BIG) file in memory, line by line, using

  • 0

I have to read a big (BIG) file in memory, line by line, using perl.
In case of some error, function open() does return false and $! is set to the system error.
But, if I get some errors reading the file?
I use this code:

open(STATISTICS, "<" . $statisticsFile) or die "Can't open statistics file $statisticsFile ($!)";
while (<STATISTICS>) {
  my $line = $_;
  ...
}
close($STATISTICS);

Any hint?

  • 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-08T06:29:35+00:00Added an answer on June 8, 2026 at 6:29 am

    You can change your code to work as shown below.

    You seem to be using both STATISTICS and $STATISTICS for your file handle. Since lexical handles are prefereable I have used $stat here.

    open my $stat, "<" . $statisticsFile
        or die "Can't open statistics file $statisticsFile: $!";
    
    until (eof $stat) {
      my $line = <$stat>;
      defined $line or die "Read failure on statistics file $statisticsFile: $!";
      ...
    }
    
    close($stat);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Some issues trying to read a file with cbc.read.table function in R
Currently I have: 1 file with 9 million lines BufferedReader.readLine() to read every line
I have this quite big CSV file (15 Gb) and I need to read
I have read some of the questions and answers here, but it none match
I've slurped in a big file using File::Slurp but given the size of the
I have file about 4MB (which i called as big one)...this file has about
Possible Duplicate: Python: How to read huge text file into memory To process a
I have the need to compress a one Big file (~450 Mbyte) through the
I have a tough problem right now. I am having a big dictionary file
I have to copy and do some simple processing on file. I can not

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.