Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl Invalid conversion in printf

Tags:

printf

perl

I have an error code:

Invalid conversion in printf: "%A"' printing %A characters in a URL

Here is my code:

$url =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;
printf "%-10s $url\n", $res_request{$key};

How can I fix this?

Thank you very much, AL

like image 730
Alfons Avatar asked Mar 07 '26 17:03

Alfons


1 Answers

Instead of putting $url in the format string, use an %s format:

printf "%-10s %s\n", $res_request{$key}, $url;

(You should never interpolate variables into the format string that have parts that may be mistaken for formatting codes.)

like image 135
ysth Avatar answered Mar 09 '26 20:03

ysth