in reply to Re: Need help with pagination
in thread Need help with pagination

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Need help with pagination
by Corion (Patriarch) on Dec 31, 2022 at 10:44 UTC

    So you have a plain syntax error in your code. I'm not sure how that relates to your title of "help with pagination", since pagination doesn't seem to be involved in the syntax error.

    Somewhere in your code you have a lone < sign, which Perl interprets as opening a <...> operator.

    My suggestion is to start ripping out stuff from the top until the error disappears. Most likely it is a badly quoted HTML string where the double quote is missing a \ before it. A text editor with syntax highlighting might also help indicate the bad string.

    You can quickly test if your found the bad string by running

    perl -wc C:/xampp/perl/lib/Article.pm
      Hm really strange it got me another error
      $string .= "<a href=\"/cgi-bin/recordz.cgi?ng=$lang&amp;page=main&sess +ion=$session_id&amp;min_index_our_selection=$min_index&amp;max_index_ +our_selection=$max_index&amp;country_swiss=$country_swiss&amp;country +_france=$country_france&amp;with_lang_french=$with_lang_french&with_l +ang_german=$with_lang_german&amp;with_lang_italian=$with_lang_italian +&amp;with_lang_english=$with_lang_english\" ><-$j-></a>&#160;&nbsp;";
      Can't modify constant item in scalar assignment at C:/xampp/perl/lib/Article.pm line 143, near "amp;" Everything worked well ...

        You have to be very careful when building html like this, otherwise you'll keep running into the problems you are posting about now. Separating your code from the HTML using a templating module is a great start, using a modern framework (such as Mojolicious::Lite) to do the heavy lifting for you will save you a lot of time once you get used to it.

        Again, this is likely a syntax error far more upwards in the source code.

        Reduce your code and/or restore the original version from backup.

        As a first step, I recommend changing all double quotes to be seen by Perl to a qq construct:

        $string .= qq{<a href=\"/cgi-bin/recordz.cgi?ng=$lang&amp;page=main&se +ssion=$session_id&amp;min_index_our_selection=$min_index&amp;max_inde +x_our_selection=$max_index&amp;country_swiss=$country_swiss&amp;count +ry_france=$country_france&amp;with_lang_french=$with_lang_french&with +_lang_german=$with_lang_german&amp;with_lang_italian=$with_lang_itali +an&amp;with_lang_english=$with_lang_english\" ><-$j-></a>&#160;&nbsp; +};

        That way, if you have an unescaped double quote within that string, it will do no harm to the Perl code.

        In the long run, you might want to use a templating system (for example Template::Toolkit or the one from Mojolicious) instead of having HTML strings within your source code.

        A reply falls below the community's threshold of quality. You may see it by logging in.