Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Pack/unpack - understanding the '@' and '.' templactes

by Loops (Hermit)
on Mar 31, 2013 at 07:11 UTC ( #1026338=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    say unpack 'aaaaa@0aa', 'ABCDEFGH';   # prints ABCDEAB
    
  2. or download this
    say unpack 'aa(aaa@0)aa', 'ABCDEFGH';  # prints ABCDECD
    
  3. or download this
    say unpack 'aa(aaa@)aa', 'ABCDEFGH';  # prints ABCDEDE
    say unpack 'aa(aaa@1)aa', 'ABCDEFGH'; # prints ABCDEDE
    
  4. or download this
    say unpack '(C/xa@)3', "\003\003\003abcdef"; # prints 'bcd'
    
  5. or download this
    say unpack 'aa.', 'ABCDEFGH';  # prints AB2
    say unpack 'aaaa.', 'ABCDEFGH';  # prints ABCD4
    
  6. or download this
    say unpack 'aa./xaa', 'ABCDEFGH';  # prints ABEF
    
  7. or download this
    say unpack 'aa.aa', 'ABCDEFGH';  # prints AB2CD
    say unpack 'a(a.a)a', 'ABCDEFGH';  # prints AB1CD
    say unpack 'a(a.*a)a', 'ABCDEFGH';  # prints AB2CD
    
  8. or download this
    say unpack 'aa(aa).*/Xaa', 'ABCDEFGH';  # prints ABCDAB
    say unpack 'aa(aa.*/Xaa)', 'ABCDEFGH';  # prints ABCDAB
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2014-08-30 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls