Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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";'

In reply to Re: A BASIC interpreter to run StarTrek by cavac
in thread A BASIC interpreter to run StarTrek by GrandFather

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



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found