The humble monks really like to see supplicants at the monastery offer up some effort, some work.

Try this:

  1. Write a program that will open (see also perlopentut) a file for input, and open another file for output. Check the status of each open to be sure it succeeds. Read each line from the input file and write it to the output file.
  2. When Step 1 works, alter the program to open a file for input, and two other files for output. Read each line from the input file and output the line to both output files.
  3. When Step 2 works, alter the program to write alternating lines to the two output files, e.g., even lines to one file, odd lines to the other.
  4. When Step 3 works, you have a basic framework to read a line from a file and decide to which of two other files it should be written. Now you can think about splitting the line into individual characters after it is read (say, maybe with split), deciding if each character is alpha or numeric (perhaps with a regex; see perlrequick, perlreref, perlre), and writing each character to the appropriate file.

Get as far as you can on your own, then come back with what you have and where you are stuck and post it here (i.e., in this thread; please do not start another thread) and you may get more forthcoming replies – in fact, like that of Utilitarian, who rather beat me to the punch.


In reply to Re: To Separate alphanumeric by AnomalousMonk
in thread To Separate alphanumeric by Anonymous Monk

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.