in reply to using a variable with require
A nasty solution to the invocation problem is to use eval. If SomeModule comes from the outside world this is a really bad solution!
use strict; use warnings; my $modName = 'Getopt::Long'; my $fixedMod = $modName; $fixedMod =~ s!::!/!g; $fixedMod .= '.pm'; require $fixedMod; my $length = 24; eval "${modName}::GetOptions('length:i' => \\\$length)";
However, there may be a much better solution to your big picture issue. What are you trying to do that seems to need a require?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: using a variable with require
by geoffleach (Scribe) on Jun 22, 2022 at 13:02 UTC | |
by GrandFather (Saint) on Jun 22, 2022 at 21:25 UTC | |
by NERDVANA (Priest) on Jun 22, 2022 at 18:12 UTC | |
by ikegami (Patriarch) on Jun 22, 2022 at 13:27 UTC | |
by roboticus (Chancellor) on Jun 23, 2022 at 13:15 UTC |