Programming Wiki: Copy contents of one file into another

Programming Wiki : PerlCopyFile

WikiHomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

Copy contents of one file into another

Perl


This block of code basically copies the contents of file.in into file.out line by line. Notice the > symbol to signify a write-clobber. You can use >> to append to a file.

  open(infile, "/some/directory/file.in");
  open(outfile, ">/some/directory/file.out");
  while () {
    print outfile "$_\n";
  }
  close(outfile);

There are no comments on this page. [Add comment]

Powered by Wikka Wakka Wiki 1.1.6.0
Page was generated in 0.0244 seconds