http://qs321.pair.com?node_id=50061


in reply to What Happened...(perils of porting from c)

I went and looked.

First of all I strongly suggest using strict up at the top, it will catch even more errors for you. Of course you need to use vars as well.

After that fixing it to work is just a matter of walking through and fixing complaints. You have an extra ')' before a ||. One-line for loops need to either change the format or need the braces. There are a few undeclared variables. A few more cases where // is used instead of # for a comment. A few $ missing. (ie You want --$level rather than --level.) Your final return statement should not be there.

All of this is pretty mechanical, but I am loathe to post the final result since the resulting code is very ugly. A native Perl version of this would be easy to write and would look much nicer. Perhaps if I get some time...

  • Comment on Re (tilly) 1: What Happened...(perils of porting from c)

Replies are listed 'Best First'.
Re: Re (tilly) 1: What Happened...(perils of porting from c)
by Madams (Pilgrim) on Jan 05, 2001 at 19:10 UTC
    Hey thanx for the critique ...

    Added "use strict" , switched to a perl aware editor (boy that caught alot just switching editors)(changed @curlevel to $curlevel..the GOOD editor caught that)

    split up the stmt that had the "||" in it (that somehow fixed that), fixed the munged comments, and that oneline for loop. Now no syntax errors (yeah!)

    Mostly i am looking for someone to tell me if i got the pointer arithmetic related crap ported right .. when i use the module i'm getting some nonsense output (examples are uploaded to here).

    One thing why get rid of the "return 1;" at the end? every example of writing a module says it should return "1" to signal proper loading.
      The reason for removing the return statement is that you are not supposed to use that outside of functions (eval, do).

      Just end with:

      1;
      and it will work.

      As for the pointer logic, sorry. No energy to go through it. It looked like a mess FWIW. I would just use recursion for this problem. (OK, so you take a performance hit.)