http://www.perlmonks.org?node_id=1013466


in reply to getting wrong value

You need sprintf to assign to a scalar. You are getting the value 1 in your $line2 variable as that is what is returned by the successful printf that displays on your screen.

$ perl -E ' > my $line = 55743; > my $line2 = sprintf q{%#x}, $line; > say $line2;' 0xd9bf $

I hope this is helpful.

Cheers,

JohnGG