I would write a base class that that has the methods for getting and setting data. I would then write individual sub classes that inherit from that base class. This way, you would only have to check the type once, and bless the object into the proper class.
my @a=qw(random brilliant braindead); print $a[rand(@a)];