Alfons
Alfons

Reputation: 331

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

Upvotes: 3

Views: 3855

Answers (1)

ysth
ysth

Reputation: 98388

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

Upvotes: 10

Related Questions