From the course: Perl 5 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Use constants - Perl Tutorial
From the course: Perl 5 Essential Training
Use constants
- [Voiceover] As I've mentioned before, Perl doesn't actually have constants. But it does have a constants pragma that does an excellent approximation. It's important that you use constants wherever you would normally do so in another language. So here is a working copy of constants.pl from chapter 15 of the exercise files. And you notice here up at the top I have this "use constant". This is the form that will allow you to define many constants at once, as if you were defining a hash. And you notice that down here I have another one defined in the single constant way. And the reason for that is because it's actually using this "true" constant, which is defined in the previous one, and so if I would try to put that in here, it wouldn't work, because that constant wouldn't have been defined yet. So I'm gonna go ahead and run this, and you see that we have a number of values. These are the sorts of things that you would use a constant for. These are values that you would need in your…
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.