Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Spanish translation of pack/unpack tutorial

by Hue-Bond (Priest)
on Jun 26, 2006 at 20:29 UTC ( [id://557655]=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        struct SupplyRequest {
            time_t request_time;    // hola de solicitud
            int employee_id;        // empleado que la realiza
    ...
            short quantity;         // cantidad
            short urgent;           // ¿es urgente?
        };
    
  2. or download this
       Desplz.   Contenido (las direcciones de memoria aumentan hacia la d
    +erecha)
             0   160  44  19  62| 41  82   3   0| 98 111 120 101 115  32 1
    +11 102
                  A0  2C  13  3E| 29  52  03  00| 62  6f  78  65  73  20  
    +6f  66
    ...
                       p   a   p   e   r   c   l   i   p   s
            32     0   0   0   0   0   0   0   0|  2   0|  1   0
                  00  00  00  00  00  00  00  00| 02  00| 01  00
    
  3. or download this
        ($order_time, $monk, $itemname, $quantity, $urgent) =
            unpack( "l i Z32 s2", $rec );
    
  4. or download this
        pack  ('a8',"hello")       produce "hello\0\0\0"
        pack  ('Z8',"hello")       produce "hello\0\0\0"
        pack  ('A8',"hello")       produce "hello   "   
    ...
        unpack('Z8',"hello\0\0\0") produce "hello"
        unpack('A8',"hello   ")    produce "hello"
        unpack('A8',"hello\0\0\0") produce "hello"
    
  5. or download this
        ord(pack('b8','00100110')) produce 100 (4 + 32 + 64)
        ord(pack('B8','00100110')) produce 38 (32 + 4 + 2)
    
  6. or download this
        pack('h4','1234') produce 0x21,0x43 
        pack('H4','1234') produce 0x12,0x34
    
  7. or download this
    #!/usr/bin/perl -w
    use strict;
    
    ...
    DumpString($rec);
    $rec = pack('H4',"1234");                # debería producir 0x12,0x34
    DumpString($rec);
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 20:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found