Last active
August 29, 2015 14:01
-
-
Save scottoffen/8ad3a316cad8f4910d02 to your computer and use it in GitHub Desktop.
Declassify arguments to a perl exported/static method
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
use Scalar::Util ('blessed'); | |
###############################| Declassify |############################### | |
sub Declassify | |
{ | |
my @params = @_; | |
shift (@params) if ($params[0] eq __PACKAGE__); | |
my @args = (ref $params[0] eq 'ARRAY') ? @{$params[0]} : (); | |
my $pkg = $params[1] || __PACKAGE__; | |
my $class = blessed($args[0]) || $args[0]; | |
shift(@args) if ((defined $class) && ($class eq $pkg)); | |
return @args; | |
} | |
#########################################||######################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See my write up here for the whens, whys and hows to use this helper method.