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 code…and the values that would never change.…

Resume Transcript Auto-Scroll

Author

Released

6/11/2016

Perl is a powerful and flexible scripting language that is uniquely suited to website development, system administration, and network programming. Perl 5 was originally released in 1994, and continues to evolve. The "Modern Perl" movement has embraced its mature syntax and reusable modules. Bill Weinman has designed this course to give the Perl student enough command of the language to write efficient and effective Perl scripts and maintain existing codebases.

Watch to learn the details of the Perl syntax, from variables, conditionals, loops, and data structures to regular expressions, functions, and references. A quick-start guide is included for experienced developers who want to get up and running with Perl 5 fast, and the entire course is recommended for both new and experienced programmers alike. Later chapters cover file handling and reusing code with Perl modules, plus Perl best coding practices.