Skip to Content
Advanced Perl Programming: From Advanced to Expert
book

Advanced Perl Programming: From Advanced to Expert

by William Bo Rothwell
May 2020
Intermediate to advanced content levelIntermediate to advanced
296 pages
4h 11m
English
Apress
Content preview from Advanced Perl Programming: From Advanced to Expert
© William "Bo" Rothwell of One Course Source, Inc. 2020
W. ". RothwellAdvanced Perl Programminghttps://doi.org/10.1007/978-1-4842-5863-7_7

7. Packages and Namespaces

William “Bo” Rothwell1 
(1)
El Cajon, CA, USA
 

Novice Perl programmers typically are told that Perl has no scope by default. While not technically accurate, without packages, variables in Perl appear to be global.

Technically, most variables are not "global". Variables are stored in "namespaces" which are created by packages.

One package exists by default: the main package. To prevent accidentally overwriting variables that exist in other portions of the script, you can create additional namespaces with the package command.

If you create a Perl module that will be called by another Perl program, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Advanced Perl Programming

Advanced Perl Programming

Sriram Srinivasan
Mastering Perl

Mastering Perl

brian d foy

Publisher Resources

ISBN: 9781484258637Purchase LinkPublisher Website