Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: To Separate alphanumeric

by AnomalousMonk (Archbishop)
on Oct 07, 2010 at 09:50 UTC ( [id://863966]=note: print w/replies, xml ) Need Help??


in reply to To Separate alphanumeric

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://863966]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-04-18 07:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found