in reply to Re: Indirect variable expansion
in thread Indirect variable expansion
Don't use this code, the correct $M is only visible inside the subprocess, hence the use has to happen inside.
FWIW: you don't need to export explicitly if you use this special bash syntax. Note the missing ;
~$ M="Data::Dumper" perl -M$M -E'say $ENV{M}->VERSION' 2.188
Furthermore, -M doesn't seem to throw an error for unknown modules.
So adding warnings -w to your execution will help you catch typos
~$ M="Data::Dumb" perl -M$M -wE'say $ENV{M}->VERSION' Use of uninitialized value in say at -e line 1.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Indirect variable expansion
by etj (Priest) on Nov 18, 2024 at 12:55 UTC | |
by LanX (Saint) on Nov 18, 2024 at 14:57 UTC | |
by hippo (Archbishop) on Nov 18, 2024 at 15:41 UTC | |
by jeffenstein (Hermit) on Nov 18, 2024 at 16:10 UTC | |
by LanX (Saint) on Nov 18, 2024 at 16:35 UTC |