Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Re: Massive Search and Replace with a twist

Thread Tools

Re: Massive Search and Replace with a twist

Craig R. Dunn
Posts: n/a
> -20 A1
> -1 150# RF A105
> -20 A2
> I have been searching the internet for a possible solution and one
> involves using "regular expressions" but this is the first time I have
> ever heard this phrase. I do not know if it will help. All I really
> need to do is to find a particular line (it always starts with "-20")
> and then add an incremental number to whatever letter is there. I am
> urgently seeking anyway to avoid manually opening up 1100 records and
> editing them by hand.

Something like (there are probably shorter ways, but this should work):

### Create an array of all the files you want to
### modify, either manually or using readdir() or `ls`
### lets assume its @files

for (@files) {
$fname = $_;
my $count=1;
open (INFILE, $fname);
open (OUTFILE, ">$");
while (<INFILE>) {
if (m/^\-20 A.*/) {
print OUTFILE $_;
} else {
print OUTFILE $_;

Reply With Quote

Thread Tools

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Newbie: trying to twist my head around twisted (and python) Jean-Paul Calderone Python 2 10-13-2006 04:44 PM
Newbie: trying to twist my head around twisted (and python) Jan Bakuwel Python 1 10-11-2006 09:30 PM
Simple Javascript replace (with a twist!) of an href Evan Javascript 3 03-28-2006 09:17 PM
VPN behind PIX revisited with a routing twist sefoca Cisco 2 12-07-2004 10:57 AM
Repost: Save file on Server - with a twist. Mr Gordonz ASP .Net 3 08-07-2003 10:52 AM