I've been having a right game with HP-UX 11.11 and perl v5.8.3, though the problem is also evident with 5.6.1. I think I've found a bug basically.
Structure of program is like this. (this is not working code that will reproduce the proble, just an illustration)
The functions do_something_with() and wait_for_pid_list() are defined elsewhere.
I've used the DATA filehandle lots of time before but not, as far as I remember, when also using fork().
The problem is that it will process host1, host2, host2 correctly and then instead of returning eof() and finishing the loop the DATA filehandle will return other parts of the script, 'push @pi' for example - or 'next'.
Now - I'm going to reproduce the problem with a little script but I thought I'd ask first - has anyone else come across this problem?
Mike
To err is human,
but to really foul things up -
you require aman Mike.
Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884
Structure of program is like this. (this is not working code that will reproduce the proble, just an illustration)
Code:
while(<DATA>){
[tab]if($cpid=fork()){
[tab][tab]push @pid_list, $cpid;
[tab][tab]sleep 1;
[tab][tab]next;
[tab]} else {
[tab][tab]chomp($host=$_);
[tab][tab]for $i (1 .. $iterations){
[tab][tab][tab]do_something_with($host);
[tab][tab]exit 0;
[tab][tab]}
[tab]}
}
wait_for_pid_list(@pid_list);
__END__
host1
host2
host3
The functions do_something_with() and wait_for_pid_list() are defined elsewhere.
I've used the DATA filehandle lots of time before but not, as far as I remember, when also using fork().
The problem is that it will process host1, host2, host2 correctly and then instead of returning eof() and finishing the loop the DATA filehandle will return other parts of the script, 'push @pi' for example - or 'next'.
Now - I'm going to reproduce the problem with a little script but I thought I'd ask first - has anyone else come across this problem?
Mike
To err is human,
but to really foul things up -
you require a
Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884