PDA

View Full Version : hmmm Program Hangs!


Hamish32
01-23-2007, 02:49 PM
I have a few scripts that I run from one sub routine.

#!/usr/bin/perl

use warnings;
use strict;

require 'cleaning.pm';
require 'identify.pm';
require 'varAnalysis.pm';

runCleaningProcess();
runIdentProc();
varAnalysis();


if I run the above program it hangs 3 quarters of the way through runIdentProc();

If I comment out varAnalysis();
It runs the whole way through runIdentProc();

in each of the sub routines i have to print a lot of information to files. I am not really sure what is happening here but each part works perfectly when run independently in sequence.

Could this be some sort of Memory Issue?

I get no sort of warning it is just as though the code is in a while loop that never ends.

I then found a for loop that never ended. I commented out the sub routine that contained the for loop and I still have the same stalling.

does anyone have any ideas?

Hamish32
01-23-2007, 03:42 PM
oh I am pretty sure its a file handle problem!!!

I have the code like this, (simplified for example)



sub aSub
{

while(something)
{
print OUT "Hello\n"
printsomething();
}

}

sub printsomething
{

print OUT "hello\n";
return;

}



How would I open the file handles when each subroutine prints to the same file?

edit: I know in this example I could return the value and print it, but its not an option in my real case. I need to be able to print to the same file from the sub routine.

FishMonger
01-23-2007, 04:35 PM
oh I am pretty sure its a file handle problem!!!

I have the code like this, (simplified for example)



sub aSub
{

while(something)
{
print OUT "Hello\n"
printsomething();
}

}

sub printsomething
{

print OUT "hello\n";
return;

}



How would I open the file handles when each subroutine prints to the same file?

edit: I know in this example I could return the value and print it, but its not an option in my real case. I need to be able to print to the same file from the sub routine.
Do you really think that anyone is going to be able to tell you what's wrong by your description and looking at this nonsense code sample?

If you want us to help troubleshoot, you're going to have to show us your script. We don't have crystal balls and we're not mind readers.

KevinADC
01-23-2007, 07:18 PM
generic suggestion is to look into using IO::File, besides that, ditto fishmonger.


Check the server error logs too if possible. You might see a warning that is occuring over and over causing the script to "hang" but not terminate.

KevinADC
01-23-2007, 08:24 PM
We don't have crystal balls

well, at my age, they feel that way sometimes :( :D

Hamish32
01-24-2007, 09:39 AM
well u should. na just joking.

Was not asking you to fix the bug i know the problem was just asking how u open the file handles but its all good i can work it out.

FishMonger
01-24-2007, 04:28 PM
perldoc -f open
perldoc -f sysopen