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

Writing to Files

Status
Not open for further replies.

monkeywithagun

Technical User
Jan 9, 2005
5
US
I'm new to cgi/perl, so this is a a rather simplistic question.

I am going to be writting data to an html file using CGI.

After declaring my varibles the code would be:

open(DAT,">$sitedata") || die("Cannot Open File");
print DAT "$sitename\|$siteurl\|$description\n";
close(DAT);

Is there a limit to the ammount of characters I can write at once? And if so, can I use more than one print statment in sucession, or do i have to close the file and then append it?

Thanks a bunch,
--Paolo
 
I haven't come across a limit yet, and you can use multiple print statements while the file is open.

If you close the file and reopen as you've detailed you'll end up overwriting the file, for append
Code:
open(DAT,"[b]>>[/b]$sitedata") || die("Cannot Open File");

HTH
--Paul

cigless ...
 
Thanks. Two other quick questions:

How would I write a simple upload script (for uploading 1-3 pictures the user inputs)? If you don't want to bother explaining it a prewritten script would be fine.

2nd) I know this is the wrong forum, but it's such a basic question im sure someone knows it. I'm kinda embarrsed because i've been working with HTML for about 4 years, and have no idea how to do this. I want to resize an image using the <img> tag. I'm going to control 1 demention (width), and need the height to resize perportionally. I can't using the % operator because i want the image to be a constant width regardless of resolution.

Thanks again.
 
Question 1, Have a look at the FAQ section here in the top bar, under your post title
Question 2, The only way I think of doing it offhand is to read the graphic file, and get the size, do some math, and print the size required. I thought if you specified the width, and didn't specify the height, it would default, but I 'm sure you tried that already

HTH
--Paul

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top