Openkore.com

OpenKore Forums
It is currently 14 Nov 2019, 15:53

All times are UTC - 5 hours [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: changing file contents using open function.
PostPosted: 30 Apr 2008, 07:34 
Offline
Noob
Noob

Joined: 30 Apr 2008, 07:06
Posts: 5
i was just wondering how can i change the contents of a file using open function, for example if i have this.

open(FILE, "<:utf8", "$file");
while (<FILE>);
#we read the file to find the part we want to change
close FILE;
open(FILE, ">>:utf8", "$file"); #open to print the output
print $foo #print if it doesnt exist
#how can i do the output that changes the file?
close FILE;

or can i just delete that file and write a new file instead? how? need some little assistance, sorry im still learning perl. :?


Top
 Profile  
 
 Post subject: Re: changing file contents using open function.
PostPosted: 30 Apr 2008, 13:04 
Offline
Developers
Developers
User avatar

Joined: 04 Apr 2008, 09:50
Posts: 109
you might wanna see this even though its a macro, the eval managed to read/edit/copy/append a text file in macro delete. Assuming the oneline eval is a small plugin inside the macro.

_________________
An Overall Macro Plugins Diffs Proposal


Top
 Profile  
 
 Post subject: Re: changing file contents using open function.
PostPosted: 30 Apr 2008, 13:16 
Offline
Perl Monk
Perl Monk

Joined: 04 Apr 2008, 17:26
Posts: 811
bin12 wrote:
i was just wondering how can i change the contents of a file using open function, for example if i have this.
or can i just delete that file and write a new file instead? how? need some little assistance, sorry im still learning perl. :?


Code:
open(FILE,">","$file");

Done.

_________________
cs : ee : realist


Top
 Profile  
 
 Post subject: Re: changing file contents using open function.
PostPosted: 30 Apr 2008, 20:55 
Offline
Noob
Noob

Joined: 30 Apr 2008, 07:06
Posts: 5
ezza wrote:
bin12 wrote:

thanks for that, but its hard to read if its written in one line I'll just arrange it so it can be readable.

sli wrote:
bin12 wrote:
i was just wondering how can i change the contents of a file using open function, for example if i have this.
or can i just delete that file and write a new file instead? how? need some little assistance, sorry im still learning perl. :?


Code:
open(FILE,">","$file");

Done.

actually i want to delete/replace the contents of it not exactly the file, sorry if i post it the wrong way.

if i have a txt file containing this
foo bar

i want to change that to
foo foo or bar bar


Top
 Profile  
 
 Post subject: Re: changing file contents using open function.
PostPosted: 30 Apr 2008, 23:52 
Offline
Perl Monk
Perl Monk

Joined: 04 Apr 2008, 17:26
Posts: 811
Why the fuck does everything think I'm a noob? DO YOU SEE AN "UNLINK($FILE)" IN THERE ANYWHERE? BECAUSE I MUST BE BLIND. Jesus, maybe you shouldn't be a programmer.

_________________
cs : ee : realist


Top
 Profile  
 
 Post subject: Re: changing file contents using open function.
PostPosted: 01 May 2008, 00:27 
Offline
Noob
Noob

Joined: 30 Apr 2008, 07:06
Posts: 5
^
haha! im sorry i didnt get your post the last time. now i get it very thanks to you.. ^^

EDIT:
now it delete that part and other contents of the file. haha! ill find other solution to that


Top
 Profile  
 
 Post subject: Re: changing file contents using open function.
PostPosted: 01 May 2008, 08:26 
Offline
Perl Monk
Perl Monk

Joined: 04 Apr 2008, 17:26
Posts: 811
bin12 wrote:
EDIT:
now it delete that part and other contents of the file. haha! ill find other solution to that

http://www.google.com/search?q=perl+open+file

_________________
cs : ee : realist


Top
 Profile  
 
 Post subject: Re: changing file contents using open function.
PostPosted: 01 May 2008, 11:07 
Offline
Plain Yogurt
Plain Yogurt
User avatar

Joined: 04 Apr 2008, 09:49
Posts: 82
sli wrote:
Why the fuck does everything think I'm a noob?


trisha: no you're not :?
anyways this would be useful

_________________
Image
DARKest Ninja


Top
 Profile  
 
 Post subject: Re: changing file contents using open function.
PostPosted: 02 May 2008, 16:32 
Offline
Perl Monk
Perl Monk

Joined: 04 Apr 2008, 17:26
Posts: 811
iamanoob wrote:
sli wrote:
Why the fuck does everything think I'm a noob?


trisha: no you're not :?
anyways this would be useful

I almost had to answer the damn question twice until I realized I had to fucking yell about it.

_________________
cs : ee : realist


Top
 Profile  
 
 Post subject: Re: changing file contents using open function.
PostPosted: 03 May 2008, 22:56 
Offline
Noob
Noob

Joined: 30 Apr 2008, 07:06
Posts: 5
^
nobody tells you're a noob, what im trying to say is that you didnt get my point. im sorry if your that sensitive. :lol:

ill just store everything in array then rewrite it


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group