I am using regex in perl to convert string to hex, however, when I do this, I get a warning from either perl critic or perl:
#$test is defined, i just put the regex code snippet here...
#this will trigger a warning from perl critic
#warning: use of regex expression without "/x" expression..
$text =~ s/(.)/sprintf("%x",ord($1))/eg;
#this will trigger a a warning at run time
#warning: "uninitialized value $1 in regexp compilation"
$text =~ m{s/(.)/sprintf("%x",ord($1))/eg}x;
Is there a way to write the above code that doesn't get a warning or feedback from Perl critic?
I think the issue is because ord is handling the undefined values, and when you put in /x then checking of the regex expression thinks that the value of $1 is invalid .