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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem writing variables to a file

Status
Not open for further replies.

rshandy

Technical User
Dec 26, 2003
91
0
0
US
I use an HTML form to parse data to a perl script. While I'm able to display that data in any browser i.e. print param('size');, I can't write the param data to an external file. I tried several things, for example:

my $upname = "test.txt";

open (File, ">$upname" || die "Error opening file $upname");
print File param('size');
my $var = param('size');
print File $var;
$var = "this works";
print File $var;
close (File);

The only data that prints to the file is when I have $var = "this works".

This is ONLY happening on our local server (IIS server - windows2000). I have other perl script programs using the same type of code on our website (remote hosted)!

Is this a configuration problem on my local server???

Thanks
 
A few things that I notice..

1) Your file handles should be in all UPPERCASE. It makes it easier to find and you have less of a chance of making a typo. So change

Code:
open (FILE, ">$upname" || die "Error opening file $upname");

2)Your OR DIE should be outside the paranthesis, so change it to (and to make our error more interesting, let's add $!)
Code:
open (FILE, ">$upname") || die "Error opening file $upname because: $!");

3)As for your actual question. When in CGI and using forms, I store ALL form data into variables at the top of the script. It's easier to mess with and test variables then param('name')'s in my opinion.

Hope this helps.

cgimonk
[/code]
 
Thanks for your response. I appreciate the tips regarding format, which I changed....however, I still cannot write any data I retrieve from my form. the file opens and I can write data that is generated in the perl script but not any data coming from the form (param).

The param data can be displayed/written on screen (browser), but not to the file.

I have no problem achieving this on my remote hosted website, but I can't get it to work on our local server.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top