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
Introduction
The Function
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,
use strict;
you can type at the top,
no strict;
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,
use strict;
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,
use VERSION
e.g.
use 5.006;
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,
no VERSION;
This means that the version of the Perl interpreter may be greater than the specified one. So you would have something like:
use 5.006;
no VERSION;
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.
Chrys
Related Links
Perl BasicsPerl Data Types
Perl Syntax
Perl References Optimized
Handling Files and Directories in Perl
Perl Function
Perl Package
Perl Object Oriented Programming
Perl Regular Expressions
Perl Operators
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
Perl Scoping
Namespace in Perl
Perl Eval Function
Writing a Perl Command Line Tool
Perl Insecurities and Prevention
Sending Email with Perl
Advanced Course
Miscellaneous Features in Perl
Perl Two-Dimensional Structures
Advanced Perl Regular Expressions
Designing and Using a Perl Module
More Related Links
Perl Mailsend
PurePerl MySQL API
Perl Course - Professional and Advanced
Major in Website Design
Web Development Course
Producing a Pure Perl Library
MySQL Course
BACK