IT Community - Software Programming, Web Development and Technical Support

How do you open a file for writing?

This is a discussion on How do you open a file for writing? within the Perl forums, part of the Software Development category; How do you open a file for writing?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Perl

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-15-2007, 07:23 PM
vadivelanvaidyanathan vadivelanvaidyanathan is offline
D-Web Genius
 
Join Date: Feb 2007
Posts: 803
vadivelanvaidyanathan is on a distinguished road
Wink How do you open a file for writing?

How do you open a file for writing?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-17-2007, 03:25 AM
Gopisoft Gopisoft is offline
D-Web Sr.Programmer
 
Join Date: Feb 2007
Posts: 117
Gopisoft is on a distinguished road
Default Re: How do you open a file for writing?

Hi,

Writing (Overwriting)
We open the file for writing much like we have before, but this time we use just one > symbol before the file variable, rather than the two we used for appending:

Code:
$sitename="Discussweb";
$siteurl="http://www.Discussweb.com";
$description="A Super Discussion Site";
$sitedata="websites.txt";

# write to the data file
open(DAT,">$sitedata") || die("Cannot Open File");
print DAT "$sitename\|$siteurl\|$description\n"; 
close(DAT);
Now, the file would have only our new contents in it, and none of the old contents will remain:
Quote:
Supersite|http://www.supersite.com|A Super Duper Site
-R.Gopi
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open a file with its default program Manikandan.S ASP and ASP.NET Programming 2 03-10-2008 10:04 PM
how to Open a .pdf file on an AJAX enabled site? kingmaker ASP and ASP.NET Programming 0 08-25-2007 03:01 AM
Reading and Writing to File using UTL_FILE in ORACLE Murali Database Support 2 08-23-2007 11:12 PM
how to open and retrive text file(.txt)? una_noche Java Server Pages (JSP) 1 08-17-2007 03:27 AM
Writing MYSQL Query Recordset into external file. Murali Database Support 2 07-19-2007 08:03 AM


All times are GMT -7. The time now is 02:03 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0