$content =~ s/(BR)/YY/g;
$content =~ s/POINT_A(BR)POINT_E/YY/g;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/perl use strict; use warnings; my $string = 'BC BR BD POINT_A DN HN JN BR NK BR POINT_E BR NH BR CJ POINT_A MK NE BR BD BR POINT_E BR BD'; my @parts = split /(POINT_[AE])/,$string; for( my $i = 2; $i < $#parts; $i+=4 ) { $parts[$i] =~ s/\bBR\b/YY/g; } $string = join '', @parts; print $string;