http://www.perlmonks.org?node_id=998737


in reply to Re^3: sending a scalar to the interpreter as a command
in thread sending a scalar to the interpreter as a command

Thanks very much for your responses, guys. I've learned a lot, but I don't think I'm quite there yet. I took Kenosis's code and turned it into this:

use strict; use warnings; my @array = ([0,.95,.114,0], [1,0,0,1], [1,3,5,7]); my $var; my @a; for (my $i = 0; $i <= $#array; $i++) { $a[$i] = join ',', @{$array[$i]}; $var .= "\{\$a\[$i\]\}-"; # can't use singl +e quotes here because $i won't resolve } #my $a = join ',', @{$array[0]}; #print "$_\n" for glob "{$a[0]}-{$a[1]}-{$a[2]}"; #this line works, + but it's not dynamic, ie. always prints out exactly three lines print "$_\n" for glob $var; #this line doesn' +t work; apparently you can't resolve a variable to glob (?) print "$var\n\n"; #this line shows +what the $var variable is passing to glob in line 17

The 'for' loop works fine for the first step, but I get tripped up on the second step. I thought I might be able to push the new reference onto a variable each time through the loop and then pass that variable to glob, but I tried it with and without quotes, and it doesn't seem to work.

As for kcott's idea, try as I might, I cannot parse the following line of code:

say for glob '{' . join('}-{' => map { join ',' => split } <DATA>) . ' +}';

I understand what join does, and I also understand map and split. But the way they are combined here is a little bit beyond my ability to comprehend. For example, where is the second argument for the first join?

In any case, the problem that remains seems to be getting each row of the array together into one glob statement. If I could do that, the modified Kenosis code above would work, I think.

Thanks again to everybody for the time you have taken to help me try to get this resolved.