Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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?
[Corion]: marto: Aah ;) Yeah - I guess I'll make the first changes to the old module, by extending its test suite to be more lenient, and then the switch to the new results should still pass the test suite :-D
[Corion]: Maybe that's more "boiling a frog", but my toolkit of Machiavellian practices is fairly small

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2018-07-16 09:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (333 votes). Check out past polls.

    Notices?