Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: forming a word from an array of its bytes

by jcb (Parson)
on Apr 07, 2021 at 22:35 UTC ( [id://11130976]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @array = (1, 2, 3, 4);
    my $val = ($array[0]) | ($array[1]<< 8) | ($array[2]<<16) | ($array[3]
    +<<24);
    printf "%d\n", $val;
    
  2. or download this
    my @array = (1, 2, 3, 4);
    my $val = unpack 'L', pack 'C4', @array;
    printf "%d\n", $val;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11130976]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-05-28 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found