[snip]
> -20 A1
> -21 FLANGE BLIND
> -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, ">$fname.new");
while (<INFILE>) {
if (m/^\-20 A.*/) {
s/A/A$count/;
$count++;
print OUTFILE $_;
} else {
print OUTFILE $_;
}
}
}
|