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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:26:20+00:00 2026-06-08T20:26:20+00:00

I have a Perl script which reads three files and writes new files after

  • 0

I have a Perl script which reads three files and writes new files after reading each one of them. Everything is one thread.

In this script, I open and work with three text files and store the contents in a hash. The files are large (close to 3 MB).

I am using a loop to go through each of the files (open -> read -> Do some action (hash table) -> close)

I am noticing that the whenever I am scanning through the first file, the Perl terminal window in my Cygwin shell gets stuck. The moment I hit the enter key I can see the script process the rest of the files without any issues.

It’s very odd as there is no read from STDIN in my script. Moreover, the same logic applies to all the three files as everything is in the same loop.

Has anyone here faced a similar issue? Does this usually happen when dealing with large files or big hashes?

I can’t post the script here, but there is not much in it to post anyway.
Could this just be a problem in my Cygwin shell?

If this problem does not go away, how can I circumvent it? Like providing the enter input when the script is in progress? More importantly, how can I debug such a problem?

sub read_set
{
@lines_in_set = ();
push @lines_in_set , $_[0];
while (<INPUT_FILE>) 
    {   $line = $_;
          chomp($line);
          if ($line=~ /ENDNEWTYPE/i or $line =~ /ENDSYNTYPE/ or eof())
          {
          push @lines_in_set , $line;
          last;
          }
          else 
          {
          push @lines_in_set , $line;       
          }
    }
    return @lines_in_set;
}

——–> I think i found the problem :- or eof() call was ensuring that the script would be stuck !! Somehow happening only at the first time. I have no idea why though

  • 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-08T20:26:21+00:00Added an answer on June 8, 2026 at 8:26 pm

    The eof() call is the problem. See perldoc -f eof.

    eof with empty parentheses refers to the pseudo file accessed via while (<>), which consists of either all the files named in @ARGV, or to STDIN if there are none.

    And in particular:

    Note that this function actually reads a character and then “ungetc”s it, so isn’t useful in an interactive context.

    But your loop reads from another handle, one called INPUT_FILE.

    It would make more sense to call eof(INPUT_FILE). But even that probably isn’t necessary; your outer loop will terminate when it reaches the end of INPUT_FILE.

    Some more suggestions, not related to the symptoms you’re seeing:

    Add

    use strict;
    use warnings;
    

    near the top of your script, and correct any error messages this produces (perl -cw script-name does a compile-only check). You’ll need to declare your variables using my (perldoc -f my). And use consistent indentation; I recommend the same style you’ll find in most Perl documentation.

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

Sidebar

Related Questions

I have a Perl script, which parses datafile and writes 5 output files filled
Scenario 1: I have one wrapper Perl script which uses another Perl module and
I have Perl script which appends a new line to the existing file every
I have written a Perl script which opens a directory consisting of various files.
I have a Perl script which maps two drives, and then proceeds to copy
I have a Perl script which nests foreach loops as seen below. It takes
I have a Perl script which will allow for a file to be uploaded
I have a Perl script which calls another script. The Perl script should be
I have a Perl script which I want to run every 4 hours through
A little background: I have a perl script which is performing a number of

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.