What is the difference between these two code snippets?
-
open (MYFILE, '>>data.txt'); -
open (MYFILE, '>data.txt');
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
open (MYFILE, '>>data.txt')— Opendata.txt, keep the original data, append data from the end.open (MYFILE, '>data.txt')— Opendata.txt, delete everything inside, and write data from the start.From
perldoc -f open:It stems from the shell usage that,
cmd < file.txtto copy file into stdin,cmd > file.txtto write stdout into a file, andcmd >> file.txtto append stdout to the end of the file.