Search for '{{search_term}}'

Programming Exercises

CMOS is the Code-Maven Open Source podcast that also includes video interviews. Subscribe to this feed RSS feed with your Podcast listener app or via iTunes iTunes.

When learning a programming language, the most important thing is to practice. Here are some exercises you can do. At first I am going to follow the Perl programming course I have been teaching for many years, but of course these exercises can be solved in many other languages.

Introduction

  1. Hello World (print, documentation, comments)

Scalars

  1. Calculate Area of Rectangular (Standard I/O, if)
  2. Number guessing game (random, prompt, if)
  3. Create calculator

Files

  1. Sum of numbers in a file (open, loop +=)
  2. Analyze Apache log file (count localhost vs others, index, substr)
  3. Add more statistics
  4. Write report to file

Lists and Arrays

  1. Color selector
  2. Add numbers taken from CSV file
  3. Improve the color selector
  4. Improve number guessing game

Advanced Arrays

  1. Count digits
  2. Sort based on secondary condition
  3. Display unique rows of a file
  4. Sort mixed strings

Subroutines

Hashes, Dictionaries

  1. Count words in a file
  2. Parse HTTP GET parameters
  3. Sort scores
  4. Analyze Apache log file (count all the hits from all the clients)
  5. Parse file with variable width fields

Regular Expressions, Regexes

  1. Regex Exercises - part 1
  2. Match numbers with regex
  3. Match hexa, octal, binary numbers
  4. Match Roman numbers
  5. Split file path with regex
  6. Sort SNMP numbers
  7. Parse hours log file and create time report
  8. Parse INI or Config files.

Shell

3rd party libraries

Simple applications

  1. Exercise: Implement the wc command of Linux/Unix (word count)

Mix

  1. Send plain text e-mail
  2. Send HTML e-mail
  3. Send e-mail with attachments
  4. Compare Wikipedia translations

Web development

  1. Hello World
  2. Echo in a web application
  3. Personal Bookmarks
  4. URL Shortener
  5. TODO list
  6. Flight ticket vendor

Web crawlers

  1. Download a web page, fetch a URL
  2. TED

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus