perl script - save content to new file

  • Xdrive
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Mar 11, 2004
  • Posts: 9
  • Status: Offline

Post March 11th, 2004, 2:56 am

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
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 11th, 2004, 2:56 am

  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Joined: Jan 14, 2004
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada
  • Status: Offline

Post March 11th, 2004, 11:09 am

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

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

Post March 11th, 2004, 11:15 am

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
  • No Avatar
  • Joined: Mar 11, 2004
  • Posts: 9
  • Status: Offline

Post March 13th, 2004, 12:38 am

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

Post March 15th, 2004, 1:40 pm

Great, glad it worked. :-)

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 153 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.