in reply to Puzzler

I'm afraid this code doesn't compile (at least under 5.005 on Win32).

Can't modify return in scalar assignment at C:\puzzle.pl line 16, near + ""1";" syntax error at C:\puzzle.pl line 17, near ""$b|" if" Execution of C:\puzzle.pl aborted due to compilation errors.

Replies are listed 'Best First'.
Re: Re: Puzzler
by Anonymous Monk on Jan 20, 2001 at 02:17 UTC
    I've hacked it a bit to fix the error, I think this is still in the spirit the author had intended:

    Replace in sub z:
    ($b & $m[$p]) ne $a?return:substr($b, $p, 1) = "1"; $d == 8?$s .= "$b|" if $s !~ /$b/:&z($_, $d+1) for 0..63;

    With:
    if (($b & $m[$p]) ne $a) { return; } else { substr($b, $p, 1) = "1"; } if ($d == 8) { $s .= "$b|" if $s !~ /$b/; } else { &z($_, $d+1) for 0..63; }

    The errors go away on Perl 5.6. Is it proper to use return in that kind of switch? I'd assume its not because of the error, but do many of you use ? : instead of branching with if/else? This may have just been the author's attempt at obfuscating the code... *shrug*
Re: Re: Puzzler
by TStanley (Canon) on Jan 20, 2001 at 00:03 UTC
    Or on Linux RH 6.2 running Perl 5.005_03
    I received the exact same error.

    TStanley
    In the end, there can be only one!