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

Constants - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

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…

Contents