You could try this which will run basic programs from the command line. The docs also advertise a basic2pl which will do what you need. | [reply] |
You might want to check out the Inline::Basic module. It's probably no good long-term solution, but it might help ease the transition between old code and new with minimal downtime.
A lot of the specifics of converting the actual code in question depend on the specific dialect of BASIC, the way the code is designed and implemented currently, and what language-specific or platform-dependant features it uses. In the end you're most likely going to have to do a lot of hand-tuning after any reasonable conversion script.
Alan | [reply] |
Yeah, but the functionality of 25,000 lines of BASIC can be done in what, about 7 lines of Perl? :) | [reply] |
the functionality of 25,000 lines of BASIC can be done in what, about 7 lines of Perl?
Depends on the dialect of BASIC and also on exactly
what sort of stuff the code is doing. Some
things (e.g., simple (non-regex) string manipulation)
many dialects of BASIC are pretty good at, and you
might find 25000 lines of BASIC coming to 20000 lines
or so of Perl. On the other hand, arrays in BASIC
are fairly primitive, to say nothing of more complex
data structures, so if the problem that the code is
solving maps well onto objects or hashes you'll see
a much more substantial reduction. Some dialects
of BASIC make good use of subroutines (e.g., QBasic);
others (e.g., most line-number BASICs) don't. In
the former case some stuff may translate fairly
well. In the latter case, you're going to end up
with some *really* messy Perl code if the translation
isn't done by a human.
for(unpack("C*",'GGGG?GGGG?O__\?WccW?{GCw?Wcc{?Wcc~?Wcc{?~cc'
.'W?')){$j=$_-63;++$a;for$p(0..7){$h[$p][$a]=$j%2;$j/=2}}for$
p(0..7){for$a(1..45){$_=($h[$p-1][$a])?'#':' ';print}print$/}
| [reply] [d/l] |
While I suppose it's technically possible to translate Basic to perl, it's just not a good idea. Perl has optimizations that didn't exist back in the day, and data structures that probably weren't available for Basic. Finally, you probably have vastly more memory and CPU cycles available to you now than the original author did when the original code was written.
In the Real World, it's rare to be able to re-write something from the ground up. What a great opportunity! When you finish, you'll be the company perl expert, with all the honor and respect that is your due.
And yes, the Monastary will be here to answer the inevitable questions.
-Logan
"What do I want? I'm an American. I want more." | [reply] |
Perhaps the best way to do that is to build a pseudo compiler/decompiler. You would have to parse the Basic
code building the tree. After that you would have to
decompile that tree in Perl source. It is a hard project
and perhaps will consume an man-time effort and surely
a expertise in computer theory that will not payback.
Besides it will probably generate a not optimized perl
code, unless you spend another bucket of compiler
optimization wizardry over it.
The rewrite from scratch seems to be a better approach.
| [reply] |