From the course: Perl 5 Essential Training
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Using Carp for error messages - Perl Tutorial
From the course: Perl 5 Essential Training
Using Carp for error messages
- [Voiceover] The default installation of Perl provides a flexible error reporting module called Carp. Here's a working copy of carp.pl from chapter 14 of the exercise files. And you notice here on line six, I use Carp. And that's how we import the module. And if I run this, you see it's simply a function that calls die. And so that's a hard error, and it exits. And even though we have another line of code after the function call, it's not getting called because of this die. So if instead of this, from the Carp module, I call the carp function. And when I run this, now we get a more rich error message with a little stack trace. And in this case, it's just a warning. And so our return from function is still displaying because after the function call the script is still running. It didn't die. And this error message, we get our little error message that says, "This is an error message." And then it says what line the error was called and that function was called from line eight in our…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.