Me Again :) - Help with the Open command

They have: 109 posts

Joined: Apr 1999

Can someone just inform me of the different *things* with open.

To open a .txt for just reading you go like this:
open(variables,"<variables.txt");

Right?

What do I use to:
Open and Overwrite a .txt

and
Open and write at the bottom(or top) new info for a .txt?

They have: 5,633 posts

Joined: Jan 1970

to overwrite:
open(FILE,">variables.txt" ) ;
to append:
open(FILE,">>variables.txt" ) ;

to the top of the file doesn't work, you have to read the whole data, push your input into it, and write it back.
don't forget to chmod!!!
and before you ask:
to write to an opened file:
print FILE
"blah blah.........

cu Smiling
patrick

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

Dass:

This URL should help you out. It explains the writing and appending of files:

http://www.extropia.com/faq/perl_faq.html#write

----------
John Pollock
http://www.pageresource.com

They have: 109 posts

Joined: Apr 1999

uhhh..Whats chmod heh?

They have: 5,633 posts

Joined: Jan 1970

on a unix-based system, a script needs to have permissions, e.g. to be executed when you want to run it from your browser, or to write new files..... and so on.
i recommend the tutorial at cgi101.com
there you'll find everything you need for your first script and how to make them run on the server...
if you learn this basic-knowledge about using cgi and perl, you won't have that much problems in the future Wink

They have: 109 posts

Joined: Apr 1999

To print to a file that is already open, do you have do go
print FILENAME $variable;
or can you just go
print $variable;

They have: 5,633 posts

Joined: Jan 1970

this would print your variable in the browser window..... Sad
cu
patrick

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.