in reply to Upload a file from home dir

The CGI upload function returns a file handle, not a file name. Therefore, you don't need to open it, you can just read directly from it. From CGI:

When called with the name of an upload field, *upload()* returns a filehandle, or undef if the parameter is not a valid filehandle.

$fh = $query->upload('uploaded_file');
while (<$fh>) {
   print;
}

Replies are listed 'Best First'.
Re: Upload a file from home dir
by MonkPaul (Friar) on Apr 01, 2005 at 14:51 UTC
    Cheers, So i take it that i just ahve to code to search for stuff i need like regEx's i.e. can now be used instead sub checkFile() { print("File is now open"); @file = <FILE>; print("

    @file

    "); while($line = <FILE>) { chomp($line); if($line =~ /(^ACGTacgt)/) {next;} else { @cols = split(/\s/, $line); print("@cols"); } print("File is now closed"); } }
      Well, I'm not entirely sure what you are trying to do. First, you would use the $filehandle rather than FILE when reading from the file. Second, you are trying to read the entire file twice from the same file handle which won't work. If you want to print the entire contents of the file and then possibly print some additional information based on the regular expression, the following code may help (though I haven't tested it):
      sub checkFile() { my @file = <$filehandle>; print( "&lt;BR&gt;&lt;BR&gt;@file&lt;BR&gt;&lt;BR&gt;" ); foreach my $line ( @file ) { chomp( $line ); if( $line =~ /([^ACGTacgt])/ ) { next; } else { my @cols = split( /\s/, $line ); print( "@cols" ); } } }