By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,848 Members | 1,319 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,848 IT Pros & Developers. It's quick & easy.

input to file

P: 1
hi everyone,i m new to perl.its great.

i have a problem.i open a file by giving its name with the redirection operator in the command line like this: > xxx.txt

now whatever i type gets written in the file xxx.txt.

till here evrything is fine.but problem comes when i again execute the script with same file to which i want to pipe input.when i enter the new input the previous one gets cleared and the current one takes its place.

now the script doesnot do anything particular .its just to get an idea about writing to a file.and i just enter plain what can be done so that the previous entered material remains in the file "xxx.txt" and everytime i enter something new it gets entered in that file along with the previous material.

Mar 2 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 4,059
try >> instead of >

inputfile >> outputfile

I am not sure if it works, but give it a try.
Mar 2 '08 #2

P: 55

'>' is for opening the file in write mode and ">>" is for opening the file in append mode. So, as KevinADC has suggested,
Expand|Select|Wrap|Line Numbers
  1. inputfile >> outputfile
will work fine ..
Mar 3 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.