Win has asked for the wisdom of the Perl Monks concerning the following question:
Any suggestions as to the problem is most welcome.my $inputfile = $ARGV[0]; my $outputfile = $ARGV[1]; open (OUTPUT_FILE, ">$outputfile"); my $Request_id; my $Variable_number; my $Variable; my $Choice; my @VARIABLE; my @CHOICE; my $Command; my $Return_results; my $Component_number_old = 1; my $Component_number = 1; my $SPROC; my $unique; my $elements_in_array; my $flat_file = $inputfile; open (FLAT_FILE, "<$flat_file"); while (<FLAT_FILE>){ chomp; $Component_number_old = $Component_number; if ($_ =~ /^$/) { exit; } elsif ($_ =~ /SPROC\sName\:\s([a-z|A-Z|0-9|_]{1,100})/){ $SPROC = $1; } elsif ($_ =~ /^\*(.{36})\;(\d{1,5})\;(\d{1,5})\;([a-z|A-Z|0-9|_]{1,5 +0})\;(.{1,100})/){ push (@VARIABLE, $Variable); push (@CHOICE, $Choice); print "Hi_B\n"; $unique = $1; $Component_number = $2; $elements_in_array = $3; $Variable = $4; $Choice = $5; } if ($_ =~ /^\sEND/){ print "Hi_E\n"; push (@VARIABLE, $Variable); push (@CHOICE, $Choice); $Command = join(' ', 'EXEC', $SPROC, join(', ', @CHOICE[1 .. $elements_in_array])) . ';'; my $Request_id = $CHOICE[26]; Got_Command($Command, $Request_id, $outputfile); undef @CHOICE; my @CHOICE; } } close FLAT_FILE; sub Got_Command { my($Command,$Request_id, $outputfile) = @_; my $sthB_A = $dbh->do($Command) or die "Couldn't do query: ".$dbh-> +errstr; my $Return_results = "Select * from Result_storage_keep where Unique +_identifier LIKE '".$Request_id."' AND Aggregated_area = Instance_nam +e AND Disease_cat = Cause_catagory\;"; my $sth_C = $dbh->prepare($Return_results) or die "Couldn't prepare +query: ".$dbh->errstr; $sth_C->execute() or die "Couldn't execute query: ".$sth_C->errstr; while (my @row = $sth_C->fetchrow_array) { print OUTPUT_FILE join("\t", @row); print OUTPUT_FILE "\n"; ## This is the bit that causes me problems ## I get the error messages # print() on closed filehandle OUTPUT_FILE at 20_October_2004_K.pl lin +e 227, <FLAT _FILE> line 29. #print() on closed filehandle OUTPUT_FILE at 20_October_2004_K.pl line + 228, <FLAT _FILE> line 29. } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: print() on closed filehandle
by davis (Vicar) on Dec 14, 2004 at 15:44 UTC | |
by Win (Novice) on Dec 14, 2004 at 15:55 UTC | |
by ikegami (Patriarch) on Dec 14, 2004 at 16:14 UTC | |
by Win (Novice) on Dec 14, 2004 at 16:28 UTC | |
by davido (Cardinal) on Dec 14, 2004 at 16:37 UTC | |
by ikegami (Patriarch) on Dec 14, 2004 at 16:53 UTC | |
| |
by fglock (Vicar) on Dec 14, 2004 at 16:46 UTC | |
| |
by davis (Vicar) on Dec 14, 2004 at 15:57 UTC | |
by Win (Novice) on Dec 14, 2004 at 16:12 UTC | |
by davis (Vicar) on Dec 14, 2004 at 16:19 UTC | |
| |
|
Re: print() on closed filehandle
by Eimi Metamorphoumai (Deacon) on Dec 14, 2004 at 15:50 UTC | |
|
Re: print() on closed filehandle
by theorbtwo (Prior) on Dec 14, 2004 at 16:37 UTC | |
|
Re: print() on closed filehandle
by ikegami (Patriarch) on Dec 14, 2004 at 16:49 UTC |