CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
CLEAN 'DIRTY' DATA FILE

 



TV005030
New User

May 3, 2010, 4:29 PM

Post #1 of 2 (2176 views)
CLEAN 'DIRTY' DATA FILE Can't Post

Hello everyone! Help, please! I am so new to Perl and I am supposed to write a script. I don't even know where to start :((( I would really appreciate if someone take the time to help me. I realize it is something easy for experienced Perl programmer. The script is supposed to:

Write a script that

A. Provides a user interface that requests the user to input a filename

B. Generates an output file called otcout.txt with following features:

1.) Lists entries in ascending alpha order (a-z)

2.) Has no quotation marks

3.) Is formatted so the columns are even

4.) Inserts the area code as (417)

5.) Inserts the exchange prefix as 447 unless specifically marked otherwise

6.) Inserts dashes between area code, exchange prefix, and line number



Samples of input and output


A. Input



"Pope, David 7274"

"Christy, Kathy 7208"

"Payne, Dennis 7035"

"Moore, Sue 7101"

"Patterson, Ty 7132"

"Church, Alan 7199"

"Williams, Amanda 7255"

"Chriswell, Arlene 7154"

"Chism, Vanda 5741"

"Childress, Layton 532-8040"

B. Output



Childress, Layton (417)-532-8040

Chism, Vanda (417)-447-5741

Christy, Kathy (417)-447-7208

Chriswell, Arlene (417)-447-7154

Church, Alan (417)-447-7199

Moore, Sue (417)-447-7101

Patterson, Ty (417)-447-7132

Payne, Dennis (417)-447-7035

Pope, David (417)-447-7274

Williams, Amanda (417)-447-7255



I have attached the input file (otcfolks.txt) with the 'dirty' data which I am supposed to format.

Thank you very much! I can't explain you how much your help means to me!

Attachments: otcfolksj.txt (7.48 KB)


rovf
Veteran

May 4, 2010, 4:24 AM

Post #2 of 2 (2156 views)
Re: [TV005030] CLEAN 'DIRTY' DATA FILE [In reply to] Can't Post


Quote
I don't even know where to start


Always start your script with the lines

use strict;
use warnings;

and since you are a beginner, also add a third line, saying

use diagnostics;

If you are really new, i.e. haven't programmed in Perl before, your exercise is pretty difficult for the first Perl program. Did you do any programming (in another language before)?

You certainly don't expect that someone will write the program for you, but for sure we will help. Start small. Ignore topic B for a moment, and concentrate to topic A. Think how the user interface is supposed to look like, and try to code this. If the code doesn't work as expected, post it, and you will get help.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives