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 23rd, 2001, 12:23 AM
wswicked wswicked is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: na
Posts: 0 wswicked User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
open file find and replace

was wondering where i could find info on opening afile finding text and then replacing it with a variable in
Thank you in advance
Wicked-

Reply With Quote
  #2  
Old July 23rd, 2001, 07:39 AM
Pressly Pressly is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 48 Pressly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Post How about this....

I believe this will do it:
Code:
open (INFILE, "</path/filename") or die "Cannot open filename for input: $!";
while (<INFILE>) {
    s/oldtext/$newtext/g;
    $replace .= $_;
}
close INFILE or die "Cannot close filename: $!";
open (OUTFILE, ">/path/filename") or die "Cannot open filename for output: $!";
print OUTFILE $replace;
close OUTFILE or die "Cannot close filename: $!";

Reply With Quote
  #3  
Old July 23rd, 2001, 08:33 AM
wswicked wswicked is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: na
Posts: 0 wswicked User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thank you I will try that today
Wicked-

Reply With Quote
  #4  
Old July 23rd, 2001, 01:37 PM
wswicked wswicked is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: na
Posts: 0 wswicked User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanx
this is the code that actually did it.

s/oldtext/$newtext/g;
$replace .= $_;

my book shows this code but no way of using it.
thanx again,

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > open file find and replace


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 3 hosted by Hostway