- Obscuring Addresses
Let's say you have a list of names and addresses one per line like so:
John Doe 123 Orange St, Big City, GA 92034
Jane Smith 1024 5th St. #129, Small Town, NH 61923
You wish to randomly modify/obscure them to protect people's privacy (or just for the fun challenge of it!).
Do it like this: For each number in the line pick one of the digits
in the number and replace it with a different digit. Don't use a 0 for
the first digit in a number as that would look funny. After processing,
the above lines might look like this:
John Doe 128 Orange St, Big City, GA 96034
Jane Smith 1022 8th St. #729, Small Town, NH 61903
- The California Election Process
For statewide elections California uses a "random alphabetic"
sort of candidates' names. This link describes that special sort:
https://www.sos.ca.gov/elections/randomized-alphabet.htm
A suggested design is this:
% perl elect.pl [-r] namefile
The file 'randlet.txt' will contain
a random permutation of the 26 letters of the alphabet.
If this file does not exist the program will generate it.
The -r option will force the file to be regenerated.
The candidate names come from a filename on the command line.
The names come one per line with first name then last name.
Jill Harmon
Gus Tribble
Walter Reston
Norma Kretschmer
For output, first print the permutation of the 26 letters.
Then get into a loop asking for district numbers.
Print out the order of candidates for that district.
Sort the candidates names (using the special random alphabetic sort)
by last name and then by first name.
- Time Sheet
When I do hourly contract work I keep my time in a plain
text file and process it with a Perl script. The file looks like this:
Jan 13 12:00-1:30, 2:15-4:35, 6:30-7:15
did work on the parsing of the
input file.
finalized the parsing, read about HTML,
cleaned up the data.
Jan 14 3:45-5:10, 9:05-11:25
polished the output
Feb 28 4:50-6:25
finished up the testing
Lines that don't begin with a space/tab are date/time lines.
The precise format should hopefully be clear from the above
examples. Indented lines are comments on what I did during
those time ranges. The script parses the file and prints a
tally of the time spent. The hourly rate and the timelog
filename could be put on the command line. Worry about
time ranges that cross noon/midnight like this:
Feb 14 11:45-1:35
Created the database tables.
Assume that one would not work more than 12 hours in a row.
- Buzzword Bingo
See this site:
http://www.logicalpoetry.com/cgi-bin/gencard.cgi
Note that each time the page is reloaded you get a
different Bingo card. The words are chosen randomly (but not
duplicated).
You do not need to make a CGI program.
Just generate an HTML file that can be loaded into the browser.
The words in the squares could come from a list in a file.
- Capital Cities
Make a script that will take a US state name on the command line
and then print the name of that state's capital.
% stcap.pl California
Sacramento
% stcap.pl Missouri
Jefferson City
This information is, of course, available on the web.
Use LWP::Simple to grab the HTML of a web page and then use a regex to pick
out the answer.
See this page: http://en.wikipedia.org/wiki/List_of_capitals_in_the_United_States.
It is harder to do the same for countries.
% ccap.pl Uganda
Kampala
% ccap.pl 'United States'
Washington
See this page: http://en.wikipedia.org/wiki/List_of_national_capitals_in_alphabetical_order.
- Any other project you have in mind.
It should be larger and more challenging than the homework
you have been doing. I'm open to suggestions!
It is always better if a project has personal relevance to you.