BEGIN { for (@deps) { my $dep = $_; $dep =~ s{::}{/}g; $dep .= ".pm"; require $dep; } }
You could indeed use eval, but you then have the tricky task of validating the name of the dependency first.
BEGIN { for my $dep (@deps) { /^\w+(?:::\w+)*\z/ or die("Invalid"); eval("use $dep; 1") or die($@); } }
In reply to Re: Use 'use' in foreach
by ikegami
in thread Use 'use' in foreach
by zidi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |