Skip to content

Instantly share code, notes, and snippets.

@scottoffen
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottoffen/8ad3a316cad8f4910d02 to your computer and use it in GitHub Desktop.
Save scottoffen/8ad3a316cad8f4910d02 to your computer and use it in GitHub Desktop.
Declassify arguments to a perl exported/static method
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;
}
#########################################||#########################################
@scottoffen
Copy link
Author

See my write up here for the whens, whys and hows to use this helper method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment