On Fri, Jun 01, 2001 at 11:09:35AM -0500, Nichole Bialczyk 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, 

Thankfully, when you open a file for apending (using '>> somefile'),
it will create the file if it doesn't exist!  No special code needed.

Run the following command a few times and cat the 'newfilehere' file
to see the results.

#!/usr/local/bin/perl -w
use strict;
$|++;

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

print FILE "Writing around " . localtime() . "\n";

close FILE;


: pseudocode -- ewww!
: if the file exists{
:      write to it
: }
: 
: if the file does not exist{
:      create it
:      write to it
: }
: 
: close the file
:  

  Casey West

-- 
Shooting yourself in the foot with Modula-2 
You perform a shooting on what might be currently a foot with what
might be currently a bullet shot by what might currently be a gun. 

Reply via email to