Q:

Perl Invalid conversion in printf

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

A:

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.)

