Cool!
A few things: Seems you developed this on Windows. Other OS are case sensitive regarding the filesystem, so the correct filename to save the BASIC program would is StarTrek.bas (note the uppercase letters).
Another thing: Perl uses "native" line endings by default. I had to convert the bas file to Unix line endings for the interpreter to work for the first test.
Here's a simple patch that should make this work on Linux and possibly also on Mac:
diff -u basicinterpreter.pl basicinterpreter_fixed.pl
--- basicinterpreter.pl 2021-08-11 15:51:20.359658237 +0200
+++ basicinterpreter_fixed.pl 2021-08-11 16:01:08.724748447 +0200
@@ -28,6 +28,8 @@
while (<$fIn>) {
chomp;
+ s/\r//g;
+ s/\n//g;
next if /^#/;
my ($lineNum, $line) = /^(\d+)\s+(.*)/;
perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|