perl script - save content to new file

  • Xdrive
  • Newbie
  • Newbie
  • Xdrive
  • Posts: 9

Post 3+ Months Ago

how to save the content in file A into file B??instead of displaying the result, how to ensure that the result is being saved into new file.
please help.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

from the command line? use command-line re-direction...

perlcript.pl > b (overwrite)
perlscript.pl >> b (append)
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

from your script? change the default output file handle...

put this in your script before any print statements...

open MYFILE, ">myfile.txt";
select MYFILE;

...all output that would have went to standard out (to your command prompt) will now to to the file handle MYFILE which points to the file myfile.txt.

Note: use ">>myfile.txt"; if you would like to append data.
  • Xdrive
  • Newbie
  • Newbie
  • Xdrive
  • Posts: 9

Post 3+ Months Ago

ok ok, thanks a lot n it can work now.
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

Great, glad it worked. :-)

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 135 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.