in reply to Pong in SDL

drose2211:

I've not used SDL, and you don't provide enough context for me to be sure. But looking at just the bit of code you presented, I'd guess one of:

I then took a look at the cpan page for SDL and noticed the link to the book. A quick search for add_show_handler finds that exact bit of code (sans comments) on page 52. I thought you were using the '>' to indicate the location of the syntax error, but in fact the book shows a '>' symbol there. I expect that's a syntax error right there.

Looking around in the text, I'm thinking they made a transposition error and it should be:

$app->add_show_handler(

Where the '>' at the end of the line should be moved left. If so, then they've made the same mistake on page 56 (and possibly elsewhere).

Update: Tweaked the first line to make it read better.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Pong in SDL
by choroba (Cardinal) on Nov 30, 2017 at 22:41 UTC
    That's probably because the pod
    C<$app->add_show_handler(>
    renders as
    $app-add_show_handler(>
    and should be written correctly as
    C<< $app->add_show_handler( >>
    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re^2: Pong in SDL
by drose2211 (Sexton) on Dec 01, 2017 at 00:01 UTC

    You were correct. The '>' was causing the syntax error. It needed to be written as $app->add_show_handler instead and that fixed the problem. Thanks for the help!