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

In reply to Re: Converting a source code by swampyankee
in thread Converting a source code by oblate kramrdc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.