use strict; use warnings; my $inp = "source.cbl"; my $out = "source.ada"; open INP, '<', $inp or die "Can't open $inp: $!"; open OUT, '>', $out or die "Can't open $out: $!"; while () { s/WORKING -STORAGE SECTION\./declare/; s/PROGRAM -BEGIN\./begin/; s/DISPLAY/PUT/; s/ACCEPT/GET/; s/PROGRAM -DONE\./END;/; print OUT; } close INP; # no worries for closing input file close OUT or die "Can't close $out: $!";