use strict; use warnings; my @pairs = ( ['WORKING -STORAGE SECTION.', 'declare'], ['PROGRAM -BEGIN.', 'begin;'], ['^DISPLAY', 'PUT'], ['^ACCEPT', 'GET'], ['PROGRAM -DONE.', 'END;'], ); while (defined (my $line = )) { $line =~ s/$_->[0]/$_->[1]/ for @pairs; print $line; } __DATA__ WORKING -STORAGE SECTION. PROGRAM -BEGIN. DISPLAY ACCEPT PROGRAM -DONE. this DISPLAY not changed this ACCEPT not changed this PROGRAM -DONE. should get fixed #### declare begin; PUT GET END; this DISPLAY not changed this ACCEPT not changed this END; should get fixed