Create a gist now

Instantly share code, notes, and snippets.

This is an example of how imports in Perl do *not* work.
#! /usr/bin/perl
use strict;
use warnings qw(all);
package Foo;
BEGIN {
*Foo::pseudoimport = sub { printf "Cool beans!\n" };
}
sub fancysub {
pseudoimport();
}
sub normalsub {
printf "Boring beans.\n";
}
CHECK {
undef *Foo::pseudoimport;
}
package Main;
my $obj = bless {}, 'Foo';
$obj->normalsub;
$obj->fancysub;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment