I take the question to ask 'how can I combine import statements', and that it says how it tried to write a module to implement the desired import statement they show but how they ran into subtle problems. (They must've misspoken so that this looks like a quest of software recommendations, and they're about to edit the question and correct that impression.)
At any rate, the desired import/pragma statement shown in the question strikes me as impossible -- for one, how to accommodate import lists that of course may differ across these modules? Once we are at it, what about pragmas? Etc.
Writing a module that assembles import statements is indeed actually tricky as one can't just pile up those import statements. But it can be done and they've done it -- see Import::Into.
From synopsis
package My::MultiExporter;
use Import::Into;
sub import {
my $target = caller;
Thing1->import::into($target);
Thing2->import::into($target, qw(import arguments));
}
# etc -- there's way, way more
Then you use My::MultiExporter;
in your program(s).
Here's a sketch for something perhaps more to the point, assembling sets of modules
package LoadModules;
use warnings;
use strict;
use feature 'say';
use Import::Into;
# Initializing this hash to all supported keys also serves as documentation
my %arg = map { $_ => '' } qw(base utils extras file all); #etc
sub import
{
my ($pack, @args) = @_;
%arg = map { $_ => 1 } @args;
my $target = caller;
warnings ->import::into($target);
strict ->import::into($target);
feature ->import::into($target, ':5.10');
if ($arg{base}) {
Getopt::Long ->import::into($target);
Const::Fast ->import::into($target);
Data::Dump ->import::into($target, qw(dd pp));
}
if ($arg{utils}) {
List::Util ->import::into($target, qw(min max));
List::MoreUtils ->import::into($target, qw(any all none uniq));
}
# ... etc ...
}
1;
Then we'd load wanted bundles as use LoadModules qw(base utils);
etc.
To take it further, have subs load bundles so that options can be combined without code repetition
sub import {
...
_load_base($target) if $arg{base};
_load_utils($target) if $arg{utils};
if ($arg{all}) {
_load_base($target);
_load_utils($target);
...
}
}
sub _load_base {
my ($target) = @_;
Getopt::Long ->import::into($target);
Const::Fast ->import::into($target);
Data::Dump ->import::into($target, qw(dd pp));
}
...
There are of course other ways to organize arguments; or just automate their processing by loading them via a dispatch table.
This approach lacks a listing of imported symbols in the program, but that is the ever present puzzle of how to best both simplify import statements and yet have imports documented.
The code above is a sketch that needs work but hopefully it is useful.
Another option is to have a separate import-by-bundle files for varying sets of options, or to combine it (multiple packages but some of them with multiple options, including similar bundles).