Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Perl script that will perform basic validation and formatting of UK postcodes. The postcodes are to be read from standard input, or from

image text in transcribed

Write a Perl script that will perform basic validation and formatting of UK postcodes. The postcodes are to be read from standard input, or from a file specified at the command line (use while () { -- }). The input lines are only to contain a postcode, with no other text, and blank lines should be ignored. The format of a UK postcode is as follows: One or two uppercase alphabetic characters followed by: between one and two digits followed by: an optional single uppercase alphabetic character followed by: a single space followed by: a single digit followed by: two uppercase alphabetic characters Alphabetic characters are those in the range A-Z. The following formatting is to be done: Remove all tabs and spaces Convert to uppercase Insert a space before the final digit and 2 letters Print out all the reformatted postcodes, indicating which are in error, and a count of valid and invalid codes at the end. Test your program using the file postcodes.txt in the labsolutions directory. Hints: Keep it simple; don't try to do all the formatting on one line of code! Do the formatting first, and then test the resulting pattern The test file has 25 valid and 5 invalid postcodes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Oil And Gas Accounting

Authors: Charlotte J. Wright, Rebecca A. Gallun

5th Edition

1593701373, 978-1593701376

More Books

Students also viewed these Accounting questions