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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:35:10+00:00 2026-06-09T22:35:10+00:00

I did some timestamp prints from within script, this piece is taking too long:

  • 0

I did some timestamp prints from within script, this piece is taking too long: almost 5 minutes to complete…!!!

fyi, the strArr array contains about 1500 string elements. (this loop runs that many times)

the file tmp_FH_SR is 27Mb and 300,000 lines of data.
the file tmp_FH_RL is 13 Mb with around 150,000 lines of data.

I have changed the names of variable to protect actual names…

in the first while loop, based on the fact that the $str was found only once in the file, i obtain another field from the matching record. I use this field to search for number of occurrences of this field in another file. Based on that output i add $str to an array.

my $tmp_srt;
foreach my $str (@strArr)
{
    my $tmp1;
    my $count=0;
    seek $tmp_FH_SR,0,0;
    while (<$tmp_FH_SR>)
    {
        my $line=$_;chomp($line);
        if ($line=~ m/\"$str\"/)
        {
            $count++;
            if ($count == 1)
            {
                my @tmp_line_ar = split(/\,/,$line);
                $tmp_str=$tmp_line_ar[10];
            }
        }
    }
    if ($count == 1)
    {
        my $k;
        seek $tmp_FH_RL,0,0;
        while (<$tmp_FH_RL>)
        {
            my $line=$_;chomp($line);
            if ($line=~m/\"$tmp_str\"/) {$k++;}
        }
        if($k == 1){push(@another_str_arr,$str);}
    }
}

how can i make it faster? read the 27mb and 13mb files in an array one time and work? I wanted to avoid that, as many other process be running on the host where this runs.

ty.

  • 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-09T22:35:11+00:00Added an answer on June 9, 2026 at 10:35 pm

    You’re going at it backwards, which is one reason why it’s taking so long.

    @strAtt is only 1500 entries, and you’re reading each file 1500 times because of your loop.

    Put the entires in @strArr in a map or use a multi-dimentional array so you can keep track of your count for each entry. Read a line from the file, then loop over the 1500 entries. You now read in the file only once.

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

Sidebar

Related Questions

Did some googling and couldn't find a clear answer on this. My assumption is
I'm having some trouble figuring this out. I have a script that checks a
Did some searches here & on the 'net and haven't found a good answer
I did some research and found that the only way to vertically center a
I did some all day learning and I figured out how to add rows
I did some work on a project on one machine, then pushed to github
Why did some processor manifacturers decide to use Little endian Big endian Middle endian
I did some testing with floating point calculations to minimize the precision loss. I
I did some research but all I could find was syncing data core with
I did some changes and then did a commit. Then I realized that I

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.