Packages & Modules
BEGIN and END Blocks
- You may define any number of code blocks named BEGIN
and END which act as constructors and destructors respectively
BEGIN { ... }
END { ... }
BEGIN { ... }
END { ... }
- Every BEGIN block is executed after the perl script is
loaded and compiled but before any other statement is executed
- Every END block is executed just before the perl
interpreter exits
Exercise |
- Run the begin_end example script.
- Take a look at the script itself (click the "begin_end" icon).
|
No
Hint
To
Start
|

begin_end
|
- The BEGIN and END blocks are particularly
useful when creating Perl modules...