Perl packages and modules


Release date:2023-10-21 Update date:2023-10-21 Editor:admin View counts:327

Label:

Perl packages and modules

Each package in Perl has a separate symbol table, which defines the syntax as follows:

package mypack;

This statement defines a file named mypack , the names of all variables and subroutines defined thereafter are stored in the symbol table associatedwith the package until another package statement.

Each symbol table has its own set of variables and subroutine names, and each group of names are irrelevant, so you can use the same variable name indifferent packages and represent different variables.

Accessing variables from one package to another can be specified by “package name + double colon (::) + variable name”.

The default symbol table for storing the names of variables and subroutines is the same as the name main is associated with the package. If you define other packages in the program, you can re-specify the main package when you want to switch back to the default symbol table:

Powered by TorCMS (https://github.com/bukun/TorCMS).