Perl pragmas

 

Perl pragmas

=====================================

[pragma]
[purpose]
=======================================

use autouse
provides a mechanism so that only functions in a module are called to load that module at runtime

 

use base
lets programmers declare derived classes based on parent classes listed at compile time, eliminating the need to use require.

For example, use base qw(AB) ; equivalent to BEGIN{ requireB::push(@ISA, qw(AB));}

 

use bytes
Before Perl 5.6 all strings were treated as a sequence of bytes. Strings can now contain a wider range of bytes than numeric encoded bytes. The bytes pragma specifies that the code uses the old byte-oriented semantics described above

 

use constant
declares a named symbol representing the specified scalar or list constant. For example:
use constant BUFFER_SIZE=>4096;
use constant OS=>'Solaris';

 

use diagnostics
forces more detailed information to be displayed in addition to the diagnostic information emitted by the Perl compiler and interpreter. Since it can only affect the innermost block, it is generally necessary to place the pragma at the beginning of the program. cannot use no diagnostics

 

use integer
This is a lexical domain pragma that tells the compiler to treat all arithmetic operations as integer arithmetic, i.e. to round off the fractional part of a floating-point number when performing these operations

 

use locale
This is a lexical domain pragma that tells the compiler to enable or disable the POSIX locale when processing operations such as regular expressions, built-ins, or character conversions

 

use open
declares the specification of one or more I/O operations; the two currently supported are :raw and :ctlf

 

The use overload
is responsible for redefining the meaning of built-in operations when using objects. See Math::BigFloat in the standard Perl library for an example of overloaded operators

 

use strict 'vars'
uses the 'vars' parameter, requires the use of lexical variables (my) or fully qualified variable names and exported variables with package names and scope operators, otherwise it will compile errors

 

use strict 'ref'
will generate a runtime error if symbolic references are used in the script, such as typeglob

 

use strict 'subs'
raises a compile-time error if a bareword is used and it is not a predefined subroutine or file handle.

 

use strict
produces a compile-time error if a symbolic reference is used, a non-lexical variable is declared, or a bare word that is not a subroutine or file handle is used

 

use vars qw(list)
is used to declare global variables before the introduction of our

 

use warnings
This is a lexical pragma that tells the compiler to control Perl's built-in warnings more flexibly, such as the -w switch or the $^W variable

 

use lib 'library path'
loads the library at compile time, not at runtime

 

use sigtrap 'signal names'
specifies a set of symbol handlers for initializing the listed symbols. If you do not use a default set of symbols as parameters, the program stack information will be printed and the ABRT signal will be issued

 

use subs qw(subroutine list)
A pre-declared list of subroutines, so that the listed subroutines can be called without parentheses and override the original built-in functions

 

no integer
To turn off or not output a pragma, simply prefix the pragma with no

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327080283&siteId=291194637