One problem is this line:
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.open targetfile, ">", "source.ada" or die "Can't open: $!";
Another problem is that lines such as
print targetfile tr/ACCEPT/GET/;
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.
In reply to Re: Converting a source code
by swampyankee
in thread Converting a source code
by oblate kramrdc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |