One way would be to do something like this:
open(FILE,'41084109.udp'); $/=\4; $a = <FILE>; $b = <FILE>;
The $/ variable determines how much to read in. In this case its set to 4, to read in 4 bytes (its default value is "\n").

This might be more useful if you need more than two sets of four numbers, for something like:

open(FILE,'41084109.udp'); $/=\4; while(<FILE>) { #count the occuarnce of the 4 digits $count{$_}++; }

{QA Editors note: The original question's subject line was somewhat ambiguous as to whether the person asking was trying to split a file, or a filename. The followup text was still somewhat unclear, but the example shown by the original poster clarified that he was trying to split a filename. This response will aid in splitting the contents of a file, which is different but worthy of mention.}

Originally posted as a Categorized Answer.


In reply to Re: How can I SPLIT a file name w/out delimiters ie: 41084109 by ackohno
in thread How can I split a string into fixed-length parts, rather than on delimiters? by ruyler

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.