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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:55:36+00:00 2026-05-22T02:55:36+00:00

I’m to trying to automate a data analysis program using gnuplot, essentially what I’m

  • 0

I’m to trying to automate a data analysis program using gnuplot, essentially what I’m doing is running a curve fitting program in gnuplot and then reading the log file to take out the desired values for further analysis.

Here is the section of code:

#Open curvefit log file to gather the needed coefficients
open (FILE_CURVE, 'fit.log') or die;
while (<FILE_CURVE>)
{   
    push(@log, $_);
    print "Im here\n";
}
close (FILE_CURVE);

My problem is it is not entering the while loop as I’m not seeing the print "Im here\n"; line of code.

Also at the beginning of the program I delete the log file so that it does not run away. The curve fit program re-creates it.

This is what the log file looks like. Note: there are two blank lines at the beginning of the file.

*******************************************************************************
Tue May 17 11:28:59 2011


FIT:    data read from 'temp_norm.txt' using 1:2
        #datapoints = 2000
        residuals are weighted equally (unit weight)

function used for fitting: g(x)
fitted parameters initialized with current variable values



 Iteration 0
 WSSR        : 566.797           delta(WSSR)/WSSR   : 0
 delta(WSSR) : 0                 limit for stopping : 1e-05
 lambda   : 1.49986

initial set of free parameter values

cc              = 100
dd              = 9.3

After 31 iterations the fit converged.
final sum of squares of residuals : 24.1325
rel. change during last iteration : 0

degrees of freedom    (FIT_NDF)                        : 1998
rms of residuals      (FIT_STDFIT) = sqrt(WSSR/ndf)    : 0.109901
variance of residuals (reduced chisquare) = WSSR/ndf   : 0.0120783

Final set of parameters            Asymptotic Standard Error
=======================            ==========================

cc              = 108.497          +/- 3.189        (2.939%)
dd              = 8.8375           +/- 0.0001571    (0.001777%)


correlation matrix of the fit parameters:

               cc     dd     
cc              1.000 
dd              0.246  1.000 
  • 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-05-22T02:55:37+00:00Added an answer on May 22, 2026 at 2:55 am

    A couple of issues here:

    1. It is strongly recommended to use the three-arg form of open and using a local var rather than FILEHANDLE, which will pollute your global namespace, so instead of

    open (FILE_CURVE, 'fit.log') or die;
    

    use

    open(my $fh, '<', 'fit.log') or die; 
    while(<$fh>){
    }
    close($fh);
    

    2. Deleting a file while it has an open filehandle doesn’t “really” delete it and if you read from a filehandle on a “deleted” file, you’ll simply be reading from the old file. Files are truly deleted when all links to it, including open filehandles, are removed which can take some time. One strategy you might consider is:

    sleep 1 while ! -f $path_to_logfile; # sleep until the file exists
    

    3. There’s a lib for what you want.

    Check out File::Tail
    and Filesys::Notify::Simple

    –EDIT–

    Based on your comments, I’d guess something like this is occurring:

    Assuming two agents:

    a producer (gnuplot) that writes to the log file 
    
    a consumer (your script) that reads from the log file
    
    1. producer starts

      1.1 writes to log file

    2. consumer starts

      2.1 deletes log file

      2.2 opens log file for read

      2.3 finds no lines to read

      2.4 exits

    If this is the case, then by deleting the file at 2.1 to which the producer is still writing log messages, you are creating a situation where the producer is writing to a ‘dangling’ file, one that has been removed from the file system but on which there is still on open handle.

    Then when you open the log at 2.2, the file is being recreated as an empty file which means your while loop will not find any lines and your print will not occur.

    I’d recommend either:

    1. start the consumer before you start the producer and have it wait until the log file exists to try opening it (using the sleep command above), or

    2. start the producer first but don’t delete the log file in the consumer.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker

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.