in reply to Re^2: using a variable with require
in thread using a variable with require
You can do that in a very light weight way by creating a package for each feed type. They can be in a single file or multiple files or even the main file. If not in the main file you can use or require as suits your purpose then create an instance of the appropriate type. Consider:
use strict; use warnings; package FetchOne; sub new { my ($class, %params) = @_; return bless\%params, $class; } sub type { return 'Fetch type One'; } package FetchTwo; sub new { my ($class, %params) = @_; return bless\%params, $class; } sub type { return 'Fetch type Two'; } package main; my $type = 'Two'; my $obj = "Fetch$type"->new(); print $obj->type();
Prints:
Fetch type Two
|
|---|