3

I'm getting a warning on this line of code:

$mismatch = ($_ =~ s/[^\x0]//g);

Illegal hexadecimal digit ']' ignored at xxxxxx.pl line 61. The regex looks valid to me, what is causing this error please? It's the right square bracket that it doesn't like.

Thanks!

Tenakha
  • 183
  • 1
  • 2
  • 7

1 Answers1

8

According to the perldoc.perl.org,

Similarly, \xnn, where nn are hexadecimal digits, matches the character whose native ordinal is nn. Again, not using exactly two digits is a recipe for disaster, but you can use \x{...} to specify any number of hex digits.

So, you need to use

s/[^\x00]//g

Or, s/[^\x{0}]//g.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563