{ package PerlIO::Layer; use overload q[""]=>sub {"string me!"} } $foo = PerlIO::Layer->find("raw"); print "$foo"; # Update: this only works for 5.8.x (actually only tested on 5.8.2) # and not even then if you've built a perl without layers support.