Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DATA filehandle woes...

Status
Not open for further replies.

MikeLacey

MIS
Nov 9, 1998
13,212
GB
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)
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 man Mike.

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
5.8 ain't beta any more, be sure it's reproducable
--Paul


cigless ...
 
Oh - every flipping time... :-(

Mike

To err is human,
but to really foul things up -
you require a man Mike.

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top