How to debug Perl (according to Exercism)

So in the hello world exercise for Perl, there’s this note:

" How to debug

When a test fails, a message is displayed describing what went wrong. If you would like additional output, you can use the subroutine ::YYY() around the code you would like to inspect. (:: is a shortcut for main::). This subroutine is part of the XXX module."

What does this actually end up looking like? I’ve not been successful so far and most of my searches are returning results for date-time content or generic strings.

For example, in the ETL exercise, if you wanted to debug the input data:

sub transform ($data) {

In the online test runner, the tests will contain a section called ‘Your Output’, which in this case would look something like this:

- A
- E
- I
- O
- U

at /mnt/exercism-iteration/t/../lib/ line 9

1 Like

Ah! Awesome, thank you.

Whoa! Way glad I stumbled onto this post. I missed the mentioned note in the Hello World exercise (actually, still can’t find it) and it’s been a real pill not to be able to just print out some debugging statements. I actually like the WWW method over YYY as it keeps executing rather than dying. Reading up more on the Test harness is on my ToDo list… FWIW, I run locally, so I had to install the XXX module.


That’s interesting, YYY should not be dying, only XXX and ZZZ. Do you have an example of code which dies with YYY?

1 Like

hmmmm… Apparently not. Perhaps it was XXX or I had something else wrong. It was the Anagram exercise where I first used it. But I went back through my file history and could not find a save point that failed the way I thought it did. It was also the first time I used the module so high odds I just did something wrong. I also see exactly what you say in the perldoc, so not sure what I did. I need to experiment more with it anyway just to increase my familiarity with it and working with the test harness in general.

Thanks for the correction.

P.S. Where exactly is this document? Is there more to it than this? For the life of me I cannot find it. Can someone post a link?

The information should show up in the “How to debug” section on the “Introduction” tab in the online editor. I’m not sure if this documentation is included when the CLI is used though? But since there are no instructions for installing this module, perhaps some separate information for debugging needs to be written.

1 Like

I wondered if I should check the online editor. I do everything locally and then submit through the CLI. I think I’ve only used the online editor a couple times and each time I made no code changes. Just something quirky happened when I submitted and it seemed to timeout or something, because when I opened the online editor and ran the tests, both times it just worked. I used it one other time and determined a module I installed and used locally was not available in the Exercism test area so I had to refactor without it. FWIW, The module was DateTime::Format::ISO8601.