--- Nichole Bialczyk <[EMAIL PROTECTED]> wrote:
> ok, so i know how to write to an existing file, how do i create the
> file, if it doesn't exist? i want to do something like, 
> 
> pseudocode -- ewww!

LOL!!! =o)

> if the file exists{
>      write to it
> }
> 
> if the file does not exist{
>      create it
>      write to it
> }

I'd say (without more information) that you might just try opening it
in append mode:

  open FILE, ">>$file" or die $!;

That will create it if it doesn't exist, or add to the end of one that
does. It won't let you write over stuff that's already there.

Otherwise, you could test to see if it exists:

  if (-e $file) { # you should probably check other things, too...
     # ...
  } else {
     # ...
  }

( a side note -- officially, cuddled elses like } else { are considered
naughty. Anybody know why? I find them more readable. Am I nuts?)

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

Reply via email to