At 01:18 AM 5/31/00, you wrote:
Hi,
Got a couple of good Perl language reference books, but they are completely void of examples :-(
Any one got any links etc.?
I am particularly looking for how to read values from a 'config' file, and how to create and write to text files.
Here's a small sample: $in='/etc/passwd'; # let's misuse the password file open (F,"<$in") or die "Can't open $in ($!)\n"; # try to open it for reading while (<F>) { chomp; # get rid of any trailing newlines; # split every line up in seperate fields, seperatated by ':' ($id, $passwd, $uid, $gid, $name, $home, $shell) = split /:/ ; ($shell !~ /bash/) && do { print "Warning: $id does not use bash as shell ($shell)\n"; }; } Notice that the interesting part is the split. The semantics can be changed easily to allow for any typical configfile/resource file you wish. The writing part is left as an excercise to the reader. Hint: use a hash to store the keys of the configfile HTH. Koos Pol ---------------------------------------------------------------------- S.C. Pol T: +31 20 3116122 Systems Administrator F: +31 20 3116200 Compuware Europe B.V. E: koos_pol@nl.compuware.com Amsterdam PGP public key available -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/