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"; }
In reply to Re^3: Use 'use' in foreach
by hippo
in thread Use 'use' in foreach
by zidi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |