Skip to content

Instantly share code, notes, and snippets.

@shinchit
Created December 9, 2014 21:19
Show Gist options
  • Save shinchit/80df67912529b1b1f67b to your computer and use it in GitHub Desktop.
Save shinchit/80df67912529b1b1f67b to your computer and use it in GitHub Desktop.
クラス名を得る(何らかのオブジェクトであるかどうかを判定する)方法
use Scalar::Util qw/blessed/;
my $obj = new MyClass;
if (blessed($obj)) {
print "is MyClass object.", "¥n";
print ref($obj); # you get class name (in this situation, you get MyClass)
} else {
print "is not any object.", "¥n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment