guys-

is there a way to ignore characters you are unpacking?

unpackin(); sub unpackin { my $text = 'girl,you,really,got,me,now,you,got,me,so,i,dont,know,w +hat,im,doin,666,777,99.99'; my @ar = split /,/, $text ; my @lens = map { length } @ar ; my $index = 0; my $format = ''; foreach my $len (@lens) { $format .= "A$len" . 'A'; } my $odd= 1; my @words = grep { ($odd) ? ($odd=0)+1 : ($odd=1)-1 ;} unpack($for +mat, $text ); print "( @ar )\n"; print "( @lens )\n"; print "format = $format\n"; print join "|", @words; print "\n"; }

produces

( girl you really got me now you got me so i dont know what im doin 66 +6 777 99.99 ) ( 4 3 6 3 2 3 3 3 2 2 1 4 4 4 2 4 3 3 5 ) format = A4AA3AA6AA3AA2AA3AA3AA3AA2AA2AA1AA4AA4AA4AA2AA4AA3AA3AA5A girl|you|really|got|me|now|you|got|me|so|i|dont|know|what|im|doin|666| +777|99.99
i'd love to be able to do this without having to skip every other element in the result aray...

thanks

In reply to unpack format string for ignoring chars by LanceDeeply

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.