-2

A Perl modules uses

use POSIX qw(isprint);

Which has been removed from Perl's POSIX.

Is there a work around for this?

Ghonima
  • 2,978
  • 2
  • 14
  • 23
Harry_
  • 53
  • 7

1 Answers1

4

The documentation states:

isprint

This function has been removed as of v5.24. It was very similar to matching against qr/ ^ [[:print:]]+ $ /x, which you should convert to use instead. (...)

(emphasis: me)

So I guess this very likely answers your question.

sticky bit
  • 36,626
  • 12
  • 31
  • 42
  • Yes, of course that answered the question, but it didn't actually tell me anything that my skill set can make useful. So far, the only time I have found a reference to is: `if (defined($str) && $str ne '' && !isprint($str)) {` I am still combing through all the modules in the package. Am I wanting to change: `if (defined($str) && $str ne '' && !isprint($str)) {` to `if (defined($str) && $str ne '' && !qr/ ^ [[:print:]]+ $ /x) {` ? – Harry_ May 25 '19 at 13:31
  • 2
    @Harry_: `$_` might not be set to `$str` in your context, so probably an explicit match on it is safer: `... && $str !~ qr/ ^ [[:print:]]+ $ /x ...` or skip the `qr`, it doesn't seem useful to me there (but maybe that's just me): `$str !~ m/ ^ [[:print:]]+ $ /x`. – sticky bit May 25 '19 at 13:45
  • `if (defined($str) && $str ne '' && $str ne qr/ ^ [[:print:]]+ $ /x) {` seemed to do the trick. Also commenting out the `use POSIX qw(isprint);` Thank you! – Harry_ May 25 '19 at 14:06
  • 1
    @Harry_ `$str ne qr/ ^ [[:print:]]+ $ /x` does not do what you intend. Reread sticky bit's comment if you don't know how to match a particular variable against a regular expression. – Shawn May 25 '19 at 16:34
  • 2
    @Harry_ The qr operator just creates a regex reference. You need the [m operator](https://perldoc.pl/functions/m) to test if a string matches it. – Grinnz May 25 '19 at 21:19
  • Re "*it didn't actually tell me anything that my skill set can make useful.*", Then maybe you should have asked how to match against a regex pattern? Or googled for the answer? Even googling for just `perl qr` gives [this pertinent post](https://stackoverflow.com/questions/30093272/what-is-the-meaning-of-qr-in-perl) as the second search result. – ikegami May 26 '19 at 19:49