1

When I try to use PDF::Table module on Debian Jessie (Perl 5.20), I get this message:

Useless use of greediness modifier '?' in regex; marked by <-- HERE in m/(\S{20}? <-- HERE )(?=\S)/ at /usr/share/perl5/PDF/Table.pm line 370.

This module works great on Debian Wheezy (with Perl 5.014002) but an upgrade in Perl 5.20 seems to make it unusable on Debian Jessie. The only documentation I found on this bug talks about the Perl upgrade, but doesn't give any solution to fix that. The script I use is the PDF::Table main example on CPAN:

 use strict;
 use warnings;
 use PDF::API2;
 use PDF::Table;

 my $pdftable = new PDF::Table;
 my $pdf = new PDF::API2(-file => "table_of_lorem.pdf");
 my $page = $pdf->page;

 # some data to layout
 my $some_data =[
    ["1 Lorem ipsum dolor",
    "Donec odio neque, faucibus vel",
    "consequat quis, tincidunt vel, felis."],
    ["Nulla euismod sem eget neque.",
    "Donec odio neque",
    "Sed eu velit."],
    #... and so on
 ];

my $left_edge_of_table = 50;
 # build the table layout
 $pdftable->table(
     # required params
     $pdf,
     $page,
     $some_data,
     x => $left_edge_of_table,
     w => 495,
     start_y => 500,
     start_h => 300,
     # some optional params
     next_y  => 750,
     next_h  => 500,
     padding => 5,
     padding_right => 10,
     background_color_odd  => "gray",
     background_color_even => "lightblue", #cell background color for even rows
  );

$pdf->saveas("table_of_lorem.pdf");

print "Content-type: text/html\n\n";
print "Ok";

My hoster only says that I have to "adapt my code"... Can you please help me to find the right way to do that? I only noticed this bug when using PDF::Table, but is there a possibilty to have the same problem with another Perl module on Perl 5.20? Thank you very much for your help!

Satch
  • 43
  • 8
  • Can you please check what version of PDF::Table is installed? That specific release might be broken. Run `perl -MPDF::Table\ 99` (including the space). it will complain that it only has a lower version. – simbabque Jan 20 '18 at 14:15
  • 2
    The issue you are seeing [was fixed in version 0.9.10](https://metacpan.org/changes/distribution/PDF-Table#L23). You could just install the latest version manually from CPAN, or use a local::lib for your project so it doesn't interfere with the system Perl (though for that module I think that's not an issue because it doesn't have any dependencies that might be updated besides Carp). – simbabque Jan 20 '18 at 14:18
  • Hi. I tried on perl 5.22 with PDF::API2 version 2.025 and PDF::Table version 0.9.6 and the code seems to work (write Ok and generate a pdf file) in spite of the message (which is just a warning in my view). –  Jan 20 '18 at 14:25
  • Yes, [it's a warning](http://perldoc.perl.org/perldiag.html#Useless-use-of-greediness-modifier-'%25c'-in-regex%3b-marked-by-%3c---HERE-in-m%2f%25s%2f). But you can still update. You don't _have to_ use the system packages for your Perl modules. You can install newer versions if you want. – simbabque Jan 20 '18 at 14:43
  • The version of PDF::Table installed on the server is 0.9.6. Installing the latest version (0.9.14) as a lib solves the problem on Perl 5.20. Thank you so much to both of you for your time! – Satch Jan 20 '18 at 14:58

1 Answers1

1

The problem you are seeing is a warning. It's annoying, but it can be ignored. The module was fixed in version 0.9.10. You can install that from CPAN directly instead of using the system package and then the warning will go away.

simbabque
  • 53,749
  • 8
  • 73
  • 136