Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 17th, 2001, 11:06 PM
startrader startrader is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 startrader User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
how to create a file..?

Hi,

how do i write to create a new file(html extension)?

thanks in advance
adam

Reply With Quote
  #2  
Old July 18th, 2001, 12:34 AM
jdk's Avatar
jdk jdk is offline
phpkid ~~~~~~ :o)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2000
Location: NJ, USA
Posts: 2,535 jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 11 m 11 sec
Reputation Power: 10
Send a message via Yahoo to jdk
Smile simple !!

hi startrader,

its simple to create a new file.
first decide where u want to create file.

you can try something like
Code:

 $path = 'c:/temp';
 $name = 'first.html';
 $filename = $path.$filename;	
 fopen(FILE,">$filename");

 


this code will give u file handle named FILE and you can use it to write in to that file and other stuff.

simple enough ??
right ?
best of luck,

jd

p.s: specifyin path is not compulsory but in that case file will be created in current directory of script.
__________________
_____________________________
d.k.jariwala (JD)
~ simple thought, simple act ~
I blog @ http://jdk.phpkid.org

Reply With Quote
  #3  
Old July 18th, 2001, 05:52 AM
startrader startrader is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 startrader User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hmmm i feel like an idiot.....
im trying to create some files on my server,but it doesnt create anyone? Weird...

I tested
$name = 'first.html';
open(FILE,">$name");
close(FILE);

and

$name = 'first.html';
fopen(FILE,">$name");
close(FILE);

but it didnt create any file ?

Reply With Quote
  #4  
Old July 18th, 2001, 06:59 AM
startrader startrader is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 startrader User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
now its working , i didnt chmod the directory before (777) what a newbie iam

Reply With Quote
  #5  
Old July 19th, 2001, 01:42 AM
jdk's Avatar
jdk jdk is offline
phpkid ~~~~~~ :o)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2000
Location: NJ, USA
Posts: 2,535 jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 11 m 11 sec
Reputation Power: 10
Send a message via Yahoo to jdk
Lightbulb the better method.

hi star,

fine..so u found whats goin wrong hard way..
better method is to use Perl only to report u the probs.
see whenever u have critcal functions like fopen or connecting to database use error handling.
you can do this.
Code:
	fopen(FILE,">abc.html") || error_handle("Can not open file. Reason : $!" );

	## error handle fucntion.
	sub error_handle
	{
		$error = $_[0];
		print "There is error. $error";
		exit;
	}

here || is or operator and if fopen fails then error_handle would be called. [ i hope u have some idea about || operator ]
here trick is $! . it is a perl langauge variable which holds info about what error occured last.
so that u know where u have prob.
right ??
so try to use this, it has helped me a great deal in debugging,
best of luck to u too,
jd

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > how to create a file..?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT