I use regex in perl to convert the string to hex, however, when I do this, I get a warning from perl crit 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 aa 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 does not receive warnings or feedback from a critic of Perl?
I think the problem is that ord processes undefined values, and when you put in / x, checking the regex expression considers that the value $ 1 is not valid.
source share