
PGScooter
stranger
Sep 1, 2008, 6:07 PM
Post #6 of 10
(1068 views)
|
|
Re: [tules] How to search and increment only the numbers
[In reply to]
|
Can't Post
|
|
Ah, I was confused- I thought you (Tules) were the original poster. I guess I have to get my "T" names straight. Regarding this post,
it was neccesary the way i did it because the loop would overwrite each time otherwise, I'm sure theres a way to do it otherwise by pushing them into an array before writting to file for instance, but this does the job fine. its actually quite easy to change your script to do this; no arrays needed. I do not have access to perl right now, so I cannot test it, but assuming it worked before, I think you can just move the open FILE2 outside the "while" loop. That way you don't have to append.
open(FILE, "Input.txt"); open(FILE2, ">output.txt"); while(<FILE>) { $_=~ s/(\d+)/$1 + 5/e; print FILE2 "$_";} close(FILE);close(FILE2); Regarding your other post, I looked at it, but didn't understand much. I am a still a beginner with Perl :) But if you want someone to respond, I would suggest that you write exactly (specific!) what went wrong with your script. Where there errors? If so, what where they? Post over there and you'll probably have better luck. The more you teach me, the more I learn. The more I learn, the more I teach.
|