> -----Original Message-----
> From: Raja Gopal [mailto:[EMAIL PROTECTED]]
> Subject: Request from Beginner
> 
> Hello All,
> 
>   I would like to learn PERL for handling files. 
> (Open, edit, close, write,  delete some lines, pattern
> matching..etc). I did search in the net (using
> Google.com).But I couldn't find the tutorial/e-book
> which helps beginner (like me) to learn the basics,
> becoz there are so many websites. Since I am working
> in IC design, I don't have much exposure in Software
> /Scripting. Kindly give me some pointers for
> e-book/tutorials which helps me.
> 
>  Your co-operation/help would be highly appreciated.
> 
> Thanks and Regards,
>   Raja Gopal

The most basic syntax for opening files is:
  open (FILEHANDLE, "path/to/file");  OR
  open (FILEHANDLE, "<path/to/file");  ("<" is the default, so it is not
needed)
This opens the file for reading.  Of course, you'll want to check to make
sure that you were able to open the file successfully, so you'd probably
want to use something like this:
  open (FILEHANDLE, "path/to/file") || die "Couldn't open path/to/file";
This extra code tells Perl to exit if the file could not be opened, and
prints out the message in quotes to the screen.

To open a file for writing:
  open (FILEHANDLE, ">path/to/file") || die "Couldn't open path/to/file";
This will create a new file if it does not exist, or if the file does exist,
it will clear all the contents of the file and start writing at the
beginning of the file.

To open a file for appending:
  open (FILEHANDLE, ">>path/to/file") || die "Couldn't open path/to/file";
This will open a file, and put the pointer at the end of the file to begin
your writing.

To actually write to the file:
  print (FILEHANDLE, "stuff to print");

To close a file:
  close (FILEHANDLE) || die "Couldn't close file";

Probably the best options for books are the O'Reilly books (Particularly
"Learning Perl", "Programming Perl", and "The Perl Cookbook").  These books
should give you all the information you need to get started, and of course
this list is here for any questions that arise.

Hope this helps...
Jason


CONFIDENTIALITY NOTICE:

************************************************************************

The information contained in this ELECTRONIC MAIL transmission
is confidential.  It may also be privileged work product or proprietary
information. This information is intended for the exclusive use of the
addressee(s).  If you are not the intended recipient, you are hereby
notified that any use, disclosure, dissemination, distribution [other
than to the addressee(s)], copying or taking of any action because
of this information is strictly prohibited.

************************************************************************

Reply via email to