#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    64
    Rep Power
    17

    syntax to overwrite,delete,create, copy a text file ?


    syntax to overwrite,delete,create, copy a text file ?

    hi,

    i have a text file which i use to keep some data which i will display when i run a perl script.

    what is the perl command to overwrite a text file so that i can show the new information ?

    this text file i use is called info.txt

    how do i delete create.txt and create it again ?

    what is the syntax to copy this text file to be info2.txt, info3.txt ?


    thanks
    perl / cgi newbie
  2. #2
  3. 11
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jul 2001
    Location
    Lynn, MA
    Posts
    4,635
    Rep Power
    86
    read the perl documentaion about open
    http://www.perldoc.com/perl5.6.1/pod/func/open.html
    paying particular attention to "mode".

    Here's a great tutorial on how to use the excellent documentation included with every perl distribution.

    DON'T FORGET TO LOCK YOUR FILES EVERY TIME YOU TOUCH THEM! In a multi-user environment like the web, you HAVE to lock your files on reads/writes, otherwise you're risking losing data. Maybe not today or tomorrow, but it WILL happen.

    Here's a great tutorial on why and how to lock files.

    Check out File::Copy for a cross-platform method of copying files- this is a much better option than shelling out with backticks or whatever.

IMN logo majestic logo threadwatch logo seochat tools logo