Packing and Unpacking.

Hi, I want to get output as 0x23400000345....
in the below example
How to get?
i tried out, but unable to get the answer

$r=0x234;
$t=0x345;
$y=pack('L L',$t,$r);
$x1=unpack('L!',pack('P',$y));
printf("\nThe value is $x1");

I didn't get constant output

Answer Posted / kiruthikau

use the following code.

<code>
use bigint;

my $r = 0x234;
my $t = 0x345;

my $x1 = $r << 32 | $t;

print $x1->as_hex;
</code>

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In Perl we can show the warnings using some options in order to reduce or avoid the errors. What are that options?

578


Does Perl have reference type?

520


Differentiate between arrays and list in perl.

529


What is an interpolation in perl?

555


How to merge two arrays in perl?

513






Explain grooving and shortening of arrays?

698


What are the different ways to run cgi?

484


How will you get the count of parameters passed to a perl subroutine?

530


What is the difference between perl list and perl array?

460


Explain the meaning of closure in perl.

518


Differentiate between use and require, my and local, for and foreach and exec and system

479


There are some duplicate entries in an array and you want to remove them. How would you do that?

491


What $! In perl?

519


How do you set environment variables in perl?

546


Explain what is lvalue?

597