$msg = "";
$myaddress = "sacha" + "@" + "sachachua.com";
$page = "Teaching.Perl.Exercises.php";
$page_title = "Teaching.Perl.Exercises";
$page_updated = "2004-11-21";
$http_equiv = "Content-Type";
$meta_content = "text/html; charset=utf-8";
$maintainer = "mailto:firstname.lastname@example.org";
$home = "WelcomePage.php";
$index = "WikiIndex.php";
$style = <<
Read the number of text messages sent from STDIN. Output the total cost of text messages.
Read in the number of seconds. Print out the number of pulses, rounded up. (1 pulse is 6 seconds or a fraction thereof.)
Read the number of minutes. Read the number of seconds. Output the total number of seconds.
Read the number of seconds. Convert this to standard minutes:seconds format.
Read in the type of call (DAY, NGT or SUN) and the duration of the call. Output the cost of the call.
Let's say that PLDT decides to run a special promo on IDD calls to encourage families to spend more time on the phone this Christmas season. Calls from 0 to 10 minutes are charged at the normal rate. The next 10 minutes will be charged at 75% of the full rate. If the full rate is 40c/minute, then the rate for those minutes will be 30c/minute. The remaining minutes will be charged at 50% of the full rate. If the full rate is 40c/minute, then the rate for the remaining minutes will be 20c/minute.
Illustration: If the call length is 40 minutes and the normal rate is 40c/minute, then the breakdown is as follows:
|10 minutes x 0.40 c/minute||$ 4|
|10 minutes x 0.30 c/minute||$ 3|
|20 minutes x 0.20 c/minute||$ 4|
If the call length is 15 minutes and the normal rate is 20c/minute, then
|10 minutes x 0.20 c/minute||$ 2|
|5 minutes x 0.15 c/minute||$ 0.75|
You would also like to give people a report of how much they saved by taking advantage of this promo.
Convert obscure acronyms into phrases so that you can easily understand forms. Read the acronym and print out the long form.
|OC||Int'l Person/Person Report Chg|
|OG||Nat'l Opr Ast-Globe Mobile Phone|
|OR||Int'l Person/Person Regular|
|XR||Nat'l TeleCharge (within USA)|
|Y5||Nat'l TeleCharge (within USA)|
|ZR||Nat'l TeleCharge (within USA)|
Given an area, print out the emergency numbers for that area.
For example, if the input is Angono, print out
------------------------------------------------ Angono ------------------------------------------------ Fire: 651-0064 Police: 651-0065 Patrol 117: 117 Bantay Bata: 163 Bisig Bayan: 928-4299 Meralco: 16-211, 631-1111 Manila Water Company, Inc.: 1627 Maynilad Water Services, Inc.: 1626 National Poison Control: 524-1078 MMDA: 882-0877, 882-0889 Assn. Of Volunteer Fire Chiefs and Firefighters of the Phils, Inc.: 160-16 Assn. Of Philippine Volunteer Fire Brigades, Inc.: 522-2222 Civil Defense Operation Center: 911-5061 ------------------------------------------------
Assume you are processing an international call. Read in the type of call (DAY, NGT or SUN) and the duration of the call. Output the cost of the call.
Read in the number dialed. Print out the number. If this is an IDD call (starts with 00), print out "IDD". If this is an NDD call (starts with 0), print out "NDD". If it is neither, print "Unknown."
Extend for other call types, like "International operator-assisted call" (108), "National operator-assisted call" (109), "Collect call to US/Hawaii" (1010500).
Phone numbers like 19081BULAGA are easier to remember than
Read in a number of the form "0" + Area Code + Phone No. Output just the area code. For simplicity, assume the area code is always two digits. Example: If the input is 0322310000, print out 32.
Sometimes you need to quickly look up the province based on an area code or the area code based on the toll abbreviation. Flipping through the paper phonebook takes a lot of time. Why not use a program to speed up the work?
national.txt contains a few of the national points reached by PLDT in the form
Manila to...:Toll destination abbreviation:area code:province(You can add more if you want.)
Write a program that allows you to easily look up data. For example, if you input
47it should print out all the rows that contain 47.
It's Christmas and you'd like to send Christmas cards and gifts to your most important clients based on the volume of business they do with you. Read the name of a person/organization, the type of account (BUS for business or RES for residential), and the total amount billed this year.
Come up with your own rules for determining when to send a card or what kind of gift to give. Some suggestions:
If the account is a business account If the total billed amount is greater than or equal to 500,000 Send an elaborate Christmas basket Else if the total billed amount is greater than or equal to 250,000 Send sweet ham Else if the total billed amount is greater than or equal to 100,000 Send a Christmas card Else # the account is a residential account If the total billed amount is greater than or equal to 50,000 Send an elaborate Christmas basket Else if the total billed amount is greater than or equal to 35,000 Send sweet ham Else if the total billed amount is greater than or equal to 20,000 Send a Christmas card
Take a look at clients.txt. This is a list of the form
name:telephone:type (BUS or RES):total billingclients.pl is a program that extracts the billing information from this and prints out all those with a total billing of at least 20000 (residential) or 100000 (business). Copy this program to christmas-list.pl and modify it to print out a report in this format:
Name of organization/person:telephone:Gift to give this Christmas
Another way to reward your most important customers is to give incentives to the top 50 business and residential accounts. For example, you could give Christmas baskets to your top 10, ham to the 11st to the 25th, and cards to the 26th to the 50th.
Add more entries to your clients.txt following the specified format.
name:telephone:type (BUS or RES):total billingtop-clients.pl is a program that sorts these by type and then by billing. Copy this program to christmas-list.pl and modify it to print out a report in this format:
Name of organization/person:telephone:Gift to give this ChristmasWrite a program that determines the gift to give this Christmas based on the organization/person's position.
Look at national.txt again. Write a program that prints out a sorted list of all the provinces that can be reached. Each province should be listed only once.
You will probably need arrays or hashes for this. Please see the printout of perlintro for more help. include "include/footer.inc.php" ?>