When a file is opened in write mode using “>”, the content of the existing file is deleted and content added using the print statement is written to the file. In this mode, the writing point will be set to the end of the file. So old content of file remains intact and anything that is written to file using print statement is added to the end of the file. However, read operation cannot be performed unless the file is opened in +>> mode indicating append and read.
Appending to File:
Here is how the program works:-
Step 1: Opening a file in read mode to see the existing content of the file.
Step 2: Printing the existing content of the file.
Step 3: Opening the File in Append mode to add content to the file.
Step 4: Getting text from the user to be appended to a file
Step 5: Appending text to file
Step 6: Reading the file again to see the updated content.
Step 7: Closing a file
- Perl | Basic Syntax of a Perl Program
- Perl Tutorial - Learn Perl With Examples
- Perl | Searching in a File using regex
- Perl | File Locking
- Perl | File Test Operators
- Perl | Opening and Reading a File
- Perl | Reading a CSV File
- Perl | Writing to a File
- Perl | File Upload in CGI
- Perl | File Handling Introduction
- Perl | Accessing a Directory using File Globbing
- Perl | Useful File-handling functions
- Perl | File I/O Functions
- Perl | eof - End of File Function
- How to get file input by selected file name without path using jQuery ?
- How to reset selected file with input tag file type in Angular 9?
- Perl | split() Function
- Perl | chomp() Function
- Perl | Backtracking in Regular Expression
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.