The no Function in Perl
Designing and Using a Perl Module – Part 3
Foreword: In this part of the series, I talk about the no predefined function in Perl; this function is applied in library use.
By: Chrysanthus Date Published: 2 Apr 2016
The no function does not really have a precise application. Its use depends on the context.
Used with Many Pragmas
It can be used to forbid the use of a pragma. For example, instead of typing at the top,
you can type at the top,
In this case, for the rest of the program, there is no strictness and you can declare a variable just like that, without using the my or our operator. However, this can be countermand in an inner block. That is, if at the beginning of an inner block, you type,
within that inner block, strictness applies and you have to declare a variable preceded by the my or our operator, in the block. Outside the block, strictness does not apply.
Another situation is with,
typed at the top of the current program. This means the Perl interpreter version should not be greater than 5.006. Now, you may not know the version of the Perl interpreter (or you may have some other interest); you can type at the top,
This means that the version of the Perl interpreter may be greater than the specified one. So you would have something like:
where the first line indicates the version.
There are other cases of the use of the no operator and the meaning depends on the context.
End of Tutorial and end of Series
This is the end of the tutorial and the end of the series. I hope you appreciated the series.
Related LinksPerl Basics
Perl Data Types
Perl References Optimized
Handling Files and Directories in Perl
Perl Object Oriented Programming
Perl Regular Expressions
Perl Core Number Basics and Testing
Commonly Used Perl Predefined Functions
Line Oriented Operator and Here-doc
Handling Strings in Perl
Using Perl Arrays
Using Perl Hashes
Perl Multi-Dimensional Array
Date and Time in Perl
Namespace in Perl
Perl Eval Function
Writing a Perl Command Line Tool
Perl Insecurities and Prevention
Sending Email with Perl
Miscellaneous Features in Perl
Perl Two-Dimensional Structures
Advanced Perl Regular Expressions
Designing and Using a Perl Module
More Related Links
PurePerl MySQL API
Perl Course - Professional and Advanced
Major in Website Design
Web Development Course
Producing a Pure Perl Library