package Blessed::Re; use overload q{""} => 'stringify'; sub new { my $class = shift; my $word = shift; my $self = qr/\[$word\]/; return bless $self, $class; } sub stringify { my $self = shift; my $string = overload::StrVal $self; $string =~ s/SCALAR/Regexp/; return $string; } package main; my $x = Blessed::Re->new('word'); print "Class: ",ref $x,"\n"; print "Type: ", $x =~ /=(\w+)\(/, "\n";