Learning the perl debugger: Introduction

In today’s tech forum, I locked the doors and started teaching some of the perl developers the basics of the perl debugger.

Traditionally, people avoid using the debugger due to the perception that it’s hard to use. I can sympathise; I avoided it myself for the first ten years of my perl career. My fear was overcome thanks to a couple of employees in the team at the time. They ran a small workshop for the then-small team. I realised that the debugger was not something to be feared, but respected and cherished.

With a growing awareness that many people are still debugging with print() and warn() statements scattered through the code, I started thinking about how I could share my experiences with this tool. I didn’t want it to be something that people could only learn from if they were stuck in a room with me, but I wasn’t sure what format would suit the information I wanted to share.

After many months, with the idea simmering in the back of my mind, the answer came to me, and it seemed so stupidly simple I kicked myself: use github to host and render Markdown files for the lesson content!

After this revelation, it was fairly easy to start writing lessons that would gradually introduce people to the perl debugger.

Getting Started

Over a series of exercises, you will learn how to use the perl debugger.

You should try to work through the lessons in order. Even if you don’t perform
all the exercises, you should read the lesson’s README.md file.


Clone the repository

git clone https://github.com/NET-A-PORTER/perl-debugger-tutorial.git

Change your working directory

cd perl-debugger-tutorial/

File Permissions

Make sure the permissions are correct for the .perldb files in this cloned

sh ./SETUP.sh

Debugger Configuration Files

Make sure you don’t have your own .perldb anywhere that might
interfere with the lessons and examples.

The lesson directories all have a local .perldb file that should override
any configuration in other directories – if things start to behave strangely,
please double check that there are no other files that could be influencing
the debugger’s behaviour.

Taking A Lesson

For each lesson it’s assumed you have changed your current working directory
to be that of the lesson. For example:

# change to the directory for the first lesson
cd 01.basics/
# read the lesson plan
cat README.md

# ... some time passes

# change to the directory for the second lesson
cd ../02.setup/

Viewing Markdown Files

You should be able to view, read and understand the Markdown files in any text editor.

If you’d like to have them rendered for you, check out these links:

  • http://mashable.com/2013/06/24/markdown-tools/
  • https://chrome.google.com/webstore/detail/markdown-here/elifhakcjgalahccnjkneoccemfahfoa
  • http://minhajuddin.com/2012/03/16/markdown-viewer-script-for-your-markdown-documents

Markdown Here (Chrome) with Ubuntu

If you opt to use Chrome with the Markdown Here extension, you can simply

google-chrome README.md

to open the README.md file in the current directory.

If you’d like to use the Chrome file browser

google-chrome $PWD


google-chrome ./

should both work.

Markdown Here (Chrome) with MacOS

You can open files in Chrome from the command line:

open -a "Google Chrome" README.md

If you’d like to use the Chrome file browser:

open -a "Google Chrome" $PWD


Taking the course

You should work through each lesson in order, starting with Lesson 1.

People who are unfamiliar with the debugger take around 45 minutes to work through the first five lessons. This is a good point to stop if you’re working through multiple lessons; you’ll have learned the basic commands and should be able to use the debugger with moderate confidence.

Lesson Summary

This is a summary of the commands learned in each of the lessons in this series.

01 Lesson Summary – BASICS

  • perl -d – start debugging
  • n – step through the script (‘next’) or (ENTER after first n)
  • q – quit the debugger (‘quit’)
  • R – start the script from the beginning (‘restart’)


  • x – examine a variable
  • p – print the value of a variable

03 Lesson Summary – DIGGING DEEPER

  • s – step into a function
  • r – return from a function
  • c – continue execution

04 Lesson Summary – LOOKING AROUND

  • l [line|sub] – list source code
  • v [line] – view around line
  • . – list current line
  • f [file] – view source in a file

05 Lesson Summary – BREAKPOINTS

  • b – set a breakpoint (current line)
  • b [sub] – set a breakpoint (specified function)
  • b [line] – set a breakpoint (specified line)
  • B [line] – clear a breakpoint for line
  • B * – clear all breakpoints
  • L – list break/watch/actions
Print Friendly
This entry was posted in Education, Perl and tagged , , , , by Chisel. Bookmark the permalink.

About Chisel

I've been interested in technology since my childhood (my Acorn Electron era). Commercially I've worked with C and VBA (Access) [but we don't talk about that]. In 2000 I secured my first role as a Perl Programmer and that's been my primary language since then. I dabble in bash, puppet, and a few other skills that help me dip my toe in the DevOps water, or provide a conduit beween the dev and ops worlds. I joined Net-A-Porter in November 2006 and have been happily evolving with the business since then.

Leave a Reply