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

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 ...

Replies are listed 'Best First'.
Re^5: Need help with pagination
by marto (Cardinal) on Dec 31, 2022 at 11:23 UTC

    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.

Re^5: Need help with pagination
by Corion (Patriarch) on Dec 31, 2022 at 11:14 UTC

    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.