in reply to \P{PosixPrint} back reference?
I guess you haven't used warnings. If you do, then a helpful warning is displayed. viz:
$ cat posix.pl #!/usr/bin/env perl use strict; use warnings; my $str = "ab\x{cc}"; $str =~ s/(\P{PosixPrint})/sprintf("U+%04X", $1)/eg; print "$str\n"; $ ./posix.pl Argument "Ì" isn't numeric in sprintf at ./posix.pl line 6. abU+0000 $
So the warning indicates that a numeric argument is expected but that you are providing a non-numeric value. We can fix this with ord:
#!/usr/bin/env perl use strict; use warnings; my $str = "ab\x{cc}"; $str =~ s/(\P{PosixPrint})/sprintf("U+%04X", ord $1)/eg; print "$str\n";
The moral: Always use strict and warnings.
🦛
|
|---|