From the course: Perl 5 Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Constants
- [Voiceover] Perl doesn't actually include Constants in the Definition of the Language. However, the standard Distribution does include a Pragma for this purpose. Here's a working copy of Constant dot PL from Chapter Four of the Exercise Files, while Perl does not include a Constant Type, it does have this Pragma in its Default Distribution. So you'll notice here on Line Seven, Eight, and Nine, on creating Constants using the Use Constant Pragma, and if I go ahead and run this, you'll see I have Say Pi, and there's the Pi Value, and I'm testing this Constant True, and that is working. So, as you can see the Syntax is similar to defining a Hash. You say Use Constant, and then you have the Token, the name of the Constant, then Equals and Greater-Than symbol together as one Operator, you can call it an Operator, and then the Value that that Constant is being defined as. This is pretty simple and you can see it's pretty easy to define a few Constants. On the other hand, you can also…
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.