What is wrong with this Boolean Perl syntax?

I have a hack, I need to use in these conditions:

  • This is the last page of data.
  • This is not the first page.
  • There is no data element with page size and parity.

So, I tried this code:

my $use_hack = 
   $last_page_number == $current_page_number and
   $page_number != 1 and
   $total_items % $items_per_page != 0;

And I continue to receive this warning Useless use of numeric ne (!=) in void contextabout the last condition and evaluate true when $total_items % $items_per_page = 0.

say 'NOT EVEN' if $total_items % $items_per_page != 0;  #works properly, though...

I tried various combinations of parentheses to get it right, but nothing works.

+3
source share
2 answers

, . and Perl, Perl . && . Blarg.

.

EDIT:
, Perl Best Practices ( .70) &&,||, ! - and or not - . ( , and not, or .)
!

+14

RHS:

my $use_hack = (
   $last_page_number == $current_page_number and
   $page_number != 1 and
   $total_items % $items_per_page != 0);

(=) and. Perl.

+7

Source: https://habr.com/ru/post/1736255/


All Articles