Day 13. Scope, Modules, and Importing Code

In today's lesson, we'll discuss issues concerning space and time (to complement our earlier discussions of truth and greed). By space, I'm referring to variable namespace: how variable names are managed across local and global scope, and how packages can be used to manage global variables across programs. Related to space is the capability to import code from modules into your scripts, either at compile time or runtime (thus covering the time part of today's lesson). Today we'll explore

  • The problem with global variables and various ways of controlling those variables

  • More about local variables; going beyond my and subroutines

  • Importing and using external code with modules and pragmas

  • Using modules from ...

Get Sams Teach Yourself Perl in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.