Created
November 17, 2009 22:20
-
-
Save rjbs/237325 to your computer and use it in GitHub Desktop.
abusing prototype() for API version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# if ($obj->can('foo')) { ... } | |
# if ($obj->can('foo', $api_version)) { ... } | |
# if ($obj->can('foo', $api_version, $minor_version)) { ... } | |
use strict; | |
use Number::Nary qw(n_codec); | |
my $major = 10; | |
my $minor = 5; | |
my ($enc, $dec) = n_codec('$@%'); | |
my $mj = $enc->($major); | |
my $mn = $enc->($minor); | |
prototype($sub) = ($major . ';' . $minor); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment