jorgejch has asked for the wisdom of the Perl Monks concerning the following question:

Hello guys, need some help here. When I run my code (below) I get an output like this:
    .
    .
    .
print() on unopened filehandle 16 at ./buildSqlQueries.pl line 23, <FH> line
        7813 (#1)
print() on unopened filehandle 16 at ./buildSqlQueries.pl line 19, <FH> line
        7830 (#1)
print() on unopened filehandle 16 at ./buildSqlQueries.pl line 19, <FH> line
        7831 (#1)
print() on unopened filehandle 16 at ./buildSqlQueries.pl line 23, <FH> line
        7831 (#1)
print() on unopened filehandle 16 at ./buildSqlQueries.pl line 19, <FH> line
        7848 (#1)
debug1
debug2
debug3
Can't figure what's the problem. Here's the code:
use strict; use warnings; use diagnostics; MAIN: { my $i=0; my @entry; my $path = "/home/jorge/bench/joomla/setting_laguage/jos_conte +nt.csv"; open (FH, '<', $path) or die $!; print ("debug1\n");###DEBUG while (<FH>){ print ("debug2\n");###DEBUG line 19 if (/^"(\d+)";/){ print ("debug3\n");###DEBUG line 23 $entry[$i] = $1; $i++; while (<FH>){ $entry[$i]=$_; $i++; last if (/readmore=/); } select($entry[0]); } } close (FH); }
Thank you very much for any help, Jorge

Replies are listed 'Best First'.
Re: print() on unopened filehandle error
by Corion (Patriarch) on May 02, 2009 at 20:27 UTC

    With

    select($entry[0]);

    you seem to make FH the current filehandle. Most likely because some part of the lines you're reading evaluates to (the fileno) of FH, for example, 3, which usually is the next free filehandle in many programs. See select.