[Tutor] file io and the open() function

Kirk Bailey deliberatus@my995internet.com
Mon, 19 Nov 2001 23:12:23 -0500


A novice approaches the masters and asks:

I want to open a pair of files, read from one, wtite it to another,
appeding data.

The first is a list of local users, as:

me1
me2
him
him28
usfellas
him2
nothome
soandso

I want to append '@' and the text of a variable's contents, crating the
second file and filling it with:

me1@domain.foo
me2@domain.foo
him@domain.foo
him28@domain.foo
usfellas@domain.foo
him2@domain.foo
nothome@domain.foo
soandso@domain.foo

Which will be used as a mailing list to alert users of the system of
upcoming events. 

I wanted to craft this tool to use variables for the 2 files and the
domain name, so it would be a useful general purpose tool for use by
others. Alas, when it tries to open a file with a variable providing the
namer, it halts and catches fire, barfing evilgrams at me.


Also, as I cannot tell in advance howm any entries will be in the source
file, this thing has to work in a loop until the source file is
exausted, then close both files. How do I detet the endoffile and end
politely, instead of running off the end of the thing and tripping an
error?




-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end
      My Sites:
      http://www.howlermonkey.net/ - free REAL email! list service soon!
      http://www.sacredelectron.org/ - Rants! Spleenvents!
      http://www.minorfish.org/ - The list server for some of us!

Message of the week:
R5L9W SDPQW UVN7V RUBWB I6HFP WVCUT VWRVL
W7812 LVH8V JBVK2 3CEJB TO8P3 FHFHG H7BFM
QID68 6DN6F 6M486 YQNCF JECQP 86CNP 86CTT
JIQPF ZPVGV DLFST DBUDI UIFNC BTUBS ETBOE
BTTGV DLUIF NSFBM IBSE!