oblate kramrdc has asked for the wisdom of the Perl Monks concerning the following question:
Hello guys i'm trying to convert a source code to another and
a friend of mine adviced me to use perl since it has powerful string
manipulation. And so am learning pearl... Could anyone be kind enough to help me
with this... When i run this there is no output saved in the target file...
Thanks!
use strict; open sourcefile, "source.cbl" or die "Can't open: $!"; open targetfile, "source.ada" or die "Can't open: $!"; foreach my $line (<sourcefile>) { if ($line =~ /WORKING -STORAGE SECTION./) { print targetfile tr/WORKING -STORAGE SECTION./declare;/; } elsif ($line =~ /PROGRAM -BEGIN./) { print targetfile tr/PROGRAM -BEGIN./begin;/; } elsif ($line =~ /^DISPLAY/) { print targetfile tr/DISPLAY/PUT/; } elsif ($line =~ /^ACCEPT/) { print targetfile tr/ACCEPT/GET/; } elsif ($line =~ /PROGRAM -DONE./) { print targetfile tr/PROGRAM -DONE./END;/; } else { print "none"; } } close sourcefile or die "Can't close: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Converting a source code
by duckyd (Hermit) on Aug 21, 2006 at 18:54 UTC | |
by oblate kramrdc (Acolyte) on Aug 21, 2006 at 19:10 UTC | |
|
Re: Converting a source code
by swampyankee (Parson) on Aug 21, 2006 at 19:00 UTC | |
|
Re: Converting a source code
by GrandFather (Saint) on Aug 21, 2006 at 19:04 UTC | |
by oblate kramrdc (Acolyte) on Aug 21, 2006 at 19:57 UTC | |
by GrandFather (Saint) on Aug 21, 2006 at 20:48 UTC | |
by oblate kramrdc (Acolyte) on Aug 24, 2006 at 22:00 UTC | |
by swampyankee (Parson) on Aug 21, 2006 at 22:04 UTC | |
by rvosa (Curate) on Aug 22, 2006 at 01:10 UTC | |
by oblate kramrdc (Acolyte) on Aug 24, 2006 at 21:57 UTC | |
by graff (Chancellor) on Aug 22, 2006 at 03:33 UTC | |
by oblate kramrdc (Acolyte) on Aug 24, 2006 at 21:56 UTC |