Open a file from PERL / ASP ?

J

Jack

Hi I use this all the time with .pl programs and it works great but
as soon as I put in ASP it blows up b/c it cant find the file ;
however same code works as tested in a .pl and the file DOES exist !
Any code that works for within an ASP file would be appreciated !
<%@Language="PerlScript"

if ($var ne '') {
$filename1 = 'e:\temp2\searchlog.txt';
open(OUTFILE,">>$filename1")|| die 'ERROR : external table not
found :'.$filename1."\n";
}
%>

thanks in advance, Jack
 
B

Ben Morrow

Quoth Jack said:
Hi I use this all the time with .pl programs and it works great but
as soon as I put in ASP it blows up b/c it cant find the file ;
however same code works as tested in a .pl and the file DOES exist !
Any code that works for within an ASP file would be appreciated !
<%@Language="PerlScript"

if ($var ne '') {
$filename1 = 'e:\temp2\searchlog.txt';
open(OUTFILE,">>$filename1")|| die 'ERROR : external table not

Use three-arg open and lexical FHs.

open(my $OUTFILE, '>>', $filename1) || die '...';

Use interpolation rather than the . operator.

... || die "ERROR : external table not found :$filename1\n";
found :'.$filename1."\n";

Since this message is for debugging, leave off the "\n". Then perl will
tell you where the error came from.

Include $! in your error message, then you'll know why the file couldn't
be opened. I suspect you've got a permission problem (that is, the error
is 'Access denied' rather than 'File not found').

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top