in reply to Re^2: Use 'use' in foreach
in thread Use 'use' in foreach
you can/should also check before loading if it is already loaded
You can, but should you? What benefit is gleaned by doing so?
If I simply double up the array of modules the script runs without error or warning and produces the expected results:
#!/usr/bin/env perl use strict; use warnings; use Module::Load; my @mods = ('JSON', 'CGI::Lite'); for my $mod (@mods, @mods) { load $mod; print "$mod version is " . $mod->VERSION . "\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Use 'use' in foreach
by cavac (Prior) on Jul 19, 2017 at 13:05 UTC | |
by stevieb (Canon) on Jul 19, 2017 at 13:23 UTC | |
by stevieb (Canon) on Jul 19, 2017 at 13:57 UTC | |
by RonW (Parson) on Jul 19, 2017 at 21:56 UTC |