in reply to Converting a source code

One problem is this line:

open targetfile, "source.ada" or die "Can't open: $!";
By default Perl opens files for reading, not writing. Change the open for targetfile to this:
open targetfile, ">", "source.ada" or die "Can't open: $!";
..and your output will go there.

Another problem is that lines such as

print targetfile tr/ACCEPT/GET/;

will operate on the special variable $_, but the input is going to the variable $line.

A third is that you want to use s///, not tr///; they behave quite differently. If I remember correctly, tr/PROGRAM -DONE./END;/ will replace every letter "P" with "E", letter "R" with "N", letter "O" with "D", and letter "G" with ";", and then cycle through "END;" as it runs into the letters "R", "A", "M", etc. This is probably not what you want (I'm thinking you want to change "PROGRAM -DONE." to "END;"; for that you'd need to use
$line =~ s/PROGRAM -DONE./END;/;.

I would suggest that you avoid the use of lowercase strings ("targetfile" or "sourcefile") for file handles; file handles are traditionally UPPERCASE. added in edit, see duckyd's post preceding this one or use scalar variables ($targetfile). Whether I use scalar variables or UPPERCASE strings for file handles depends on where they are in the code and where I expect to use the file handle.

emc

Experience is a hard teacher because she gives the test first, the lesson afterwards.

Vernon Sanders Law