Here is a different strategy for tackling the problem that can have some serious performance advantages:

#! perl -slw use strict; my $rec = chr(0) x 123; my @type3l = split ':', '02:10:33:15:19:10:3:18:6:4'; my $n = 0; my @type3o = map{ $n += $_; $n - $_; } @type3l; my @type3 = map \substr( $rec, $type3o[ $_ ], $type3l[ $_ ] ), 0 .. $# +type3o; my @typeOl = split ':', '02:98:11:9'; $n = 0; my @typeOo = map{ $n += $_; $n - $_; } @typeOl; my @typeO = map \substr( $rec, $typeOo[ $_ ], $typeOl[ $_ ] ), 0 .. $# +typeOo; while( <DATA> ) { substr( $rec, 0 ) = $_; if( /^03/ ) { print join '/', map $$_, @type3; } else { print join '|', map $$_, @typeO; } } __DATA__ 03002068454210482 000000004204.572011-04-14 + 19:53:41INTERNET C 750467375 ^M 0214833 + G02042954 ^M 03002068703214833 000000002558.662011-04-15 + 08:17:19INTERNET C 761212737 ^M 0211561 + 05601207284 ^M 03002068802911561 000000001463.702011-04-15 + 08:40:52INTERNET C 719807216 ^M 029911 + 00100275296 ^M

Produces:

c:\test>junk92 03/0020684542/10482 /000000004204.57/2011-0 +4-14 19:53:41/INTERNET /C /750467375 / / 02|14833 + |G02042954 | 03/0020687032/14833 /000000002558.66/2011-0 +4-15 08:17:19/INTERNET /C /761212737 / / 02|11561 + |05601207284| 03/0020688029/11561 /000000001463.70/2011-0 +4-15 08:40:52/INTERNET /C /719807216 / / 02|9911 + |00100275296| [23:23:38.05] c:\test>

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Working with fixed length files by BrowserUk
in thread Working with fixed length files by vendion

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.