As explained in the perl6 doco here , you can dynamically load the module, but
To import characters, you must define them at compile time.
So, the code in the else works because of an explicit import request <&tempfile> .
The closest that the code in the if works, what I see is this (which is mostly taken from the previous doco link):
use v6.c ; sub load-a-module($name) { require ::($name) ; my $instance = ::($name).new() ; return $instance ; } my $module = "Text::CSV" ; my $csv = load-a-module $module ; say $csv.WHAT ;
Marty
source share