On 5 March 2015 at 17:15, Brandon McCaig <bamcc...@gmail.com> wrote:

> Uri means that use is
> effectively requiring the module with a BEGIN block. That means
> that it will execute before any other code that isn't in a BEGIN
> block.
>


It may also be worth mentioning that "BEGIN" is actually a sub. A special
sub that doesn't need the sub keyword.

Calling them "blocks" here will allow you to overlook certain problems,
like potential closure behaviour closing over variables.

This is usually not a problem in practice because perl typically parses the
BEGIN sub, executes it, and then discards it, but there's an internal flag
to perl that can disable the discarding, and the results are incredibly
surprising if you don't remember this fact:
http://www.nntp.perl.org/group/perl.perl5.porters/2015/02/msg226031.html


-- 
Kent

*KENTNL* - https://metacpan.org/author/KENTNL

Reply via email to