Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!

I have this code part of my script for pagination, I am getting a warning as:

Useless use of addition (+) in void context at test.pl line 1123.
This is the line causing it:
$html = $html . qq( &nbsp;|&nbsp; <font color="#ff0000">$t2</font> ), + $i + 1;
I cant figure it out how to solve this, here is the bigger picture:
... for (my $i = 0; $i <= $pages -1; $i++) { if ($i == 0) { if ($limit != 0) { $html = $html . qq( <a href="test.pl">); my $r1 = $i + 1; $html = $html . $r1 . qq(</a>); }else { my $r2 = $i + 1; $html = $html . qq($r2); } } if ($i > 0) { if ($limit != ($i * $results_per_page)) { $html = $html . qq( &nbsp;|&nbsp; <a href="test.pl); my $r3 = $i * $results_per_page; $html = $html . $r3 . qq(">); my $t = $i + 1; $html = $html . $t . qq(</a>); }else { my $t2 = $i + 1; $html = $html . qq( &nbsp;|&nbsp; <font color="#ff0000"> +$t2</font> ), $i + 1; } } } ...
Thanks for looking!

Replies are listed 'Best First'.
Re: Useless use in void context.
by GrandFather (Saint) on Jan 16, 2014 at 03:44 UTC

    What do you intend the comma to do in that statement?

    True laziness is hard work
Re: Useless use in void context.
by NetWallah (Canon) on Jan 16, 2014 at 04:17 UTC
    Get rid of the
    , $i + 1
    It serves no purpose.

            If your eyes hurt after you drink coffee, you have to take the spoon out of the cup.
                  -Norm Crosby

Re: Useless use in void context.
by robby_dobby (Hermit) on Jan 16, 2014 at 05:10 UTC
    Here:
    $html = $html . qq(  &nbsp;|&nbsp; <font color="#ff0000">$t2</font> ), $i + 1;

    What do you intend to do with the:, $i + 1 since you already have $t2 where you have this assigned to?

    If you don't intend to do anything with it, remove the rest of the line from the comma or replace the comma with a '.' and the expression following it with $t2. You may also want to do something like:

    $html .= qq( ... );