http://www.perlmonks.org?node_id=424328

mikfire has asked for the wisdom of the Perl Monks concerning the following question:

I am working on a relatively complex series of related modules. I was trying to create a "dispatcher" to make things easier -- so you could type "Foo::Bar->new('Baz')" instead of saying "Foo::Bar::Baz->new()".

After running through several attempts involving eval and other weirdness, I found this works:

$huh = "Foo::Bar::Baz"; $huh->new();
even under "use strict". I would have thought I needed either an eval or a "no strict 'refs'" to make this work.

I am not complaining - this is great DWIMery. But why does it work?