Being aware of subclasses
I just joined the community and I wonder if I could jump straight in with a query.
I am writing a program that, given a directory with some files in it, would do the same functions to that directory, but in different ways based on the contents of the directory. That is, my directory may contain one of a number of different tests and I need to run those tests using different programs.
What I would like to be able to do is say "my $test = SomeClass->new($dir);" and have $test be set to a SomeClass::Foo, SomeClass::Bar etc. More importantly, I'd like the code to work if I, at a later time, create SomeClass::Baz.
I envision there being a detect() method with each class that says whether the given directory is suitable for this type, though clearly that could be done in new() (return undef if it's not suitable).
So, to cut a long story short, the point of my question is this: can I make SomeClass aware of subclasses before they even exist?