Hello and Welcome to the Guided Quick Tour to the Perl Documentation. Today, we will focus on two important aspects of Perl variables that will be of convenient assistance when needing to split files.

To your left, you find perlvar, also accessible as perldoc perlvar when using the command prompt. Please take a close look at the "input record separator", and especially how setting it to a reference to a number will make Perl read in records of a fixed length.

To your right, you will find binmode, also accessible as perldoc -f binmode from your command prompt. Using binmode on any filehandle has become almost mandatory on any operating system when you want to prevent any character set manipulation that Perl might perform and when you want to emancipate yourself from whatever character set your operating system believes to be current.

If you use these two features in conjunction, for example, in a loop, you can easily emulate the Unix split command, which does the same thing.

This concludes our Guided Quick Tour to the Perl Documentation, if you have further question, please read the leaflet How (Not) To Ask A Question before continuing. If you haven't received the leaflet at the start of the tour, there is an online version available as well.


In reply to Re: Split a file by Corion
in thread Split a file by swift

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.