Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Spanish translation of pack/unpack tutorial

by Hue-Bond (Priest)
on Jun 26, 2006 at 20:29 UTC ( #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
Node Status?
node history
Node Type: perltutorial [id://557655]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-12-29 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (184 votes), past polls