I'm trying to convert a series of strings

MOVE 4 TO INT1.
DISPLAY 'MEMBERS OF THE GROUP'.
DISPLAY INT1.

to

INT1 := 4;
PUT("MEMBERS OF THE GROUP : ");
PUT(INT1);

I used this codes:

use strict; use warnings; my $SOURCEFILE; my $TARGETFILE; my $REPORTFILE; my $converted; my $discarded; my $holder; print "Enter filename to convert: "; chomp($SOURCEFILE = <STDIN>); print "Save to:"; chomp($TARGETFILE =<STDIN>); print "Save Conversion Report to:"; chomp($REPORTFILE =<STDIN>); open SOURCEFILE, '<', $SOURCEFILE or die "Can't open $SOURCEFILE: $!"; open TARGETFILE, '>', $TARGETFILE or die "Can't open $TARGETFILE: $!"; open REPORTFILE, '>', $REPORTFILE or die "Can't open $REPORTFILE: $!"; $converted=0; $discarded=0; sub reporting { print TARGETFILE $holder; print REPORTFILE " -> "; print REPORTFILE $holder; $converted++; } foreach my $line (<SOURCEFILE>) { if($line =~ /\bDISPLAY\s'([^']*)'\./) { $line = "PUT(\"$1\");\n"; $holder = $line; reporting; } elsif ($line =~ /\bMOVE/) { print REPORTFILE $line; $line =~ m/MOVE (\d+) TO ([\d\w]+)/; print TARGETFILE "$2 := $1;\n"; print REPORTFILE " -> "; print REPORTFILE "$2 := $1;\n"; $converted++; } else { $discarded++; print REPORTFILE "<xx> "; print REPORTFILE $line; } } print REPORTFILE "No. of Keywords Converted: "; print REPORTFILE $converted, "\n"; print REPORTFILE "No. of Keywords Discarded: "; print REPORTFILE $discarded, "\n"; close SOURCEFILE or die "Can't close: $!"; close TARGETFILE or die "Can't close: $!"; close REPORTFILE or die "Can't close: $!";
The problem is:

1. How do I switch the position of INT and 4?
2.And how do I replace the TO to :=
3. After the the DISPLAY ' was changed to PUT(". How do I change the '. at the end of the sentence to ");

I'm still learning PERL your inputs are really appreciated!
Thanks in advance!

Edited by planetscape - added readmore tags

( keep:3 edit:24 reap:0 )


In reply to switching parts of a text 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.