in reply to RFC: Playing with glob
Who needs glob? It's almost a one-liner.
Toss out space holder, it's not needed,
and use $" for the joiner string since it's already used for that :)
(local $" = "somejoiner" if you want to).
#!/usr/bin/perl # http://perlmonks.org/?node_id=1142125 use strict; use warnings; sub glob_array { my @ans = @{pop()}; @ans = map{ my $i = $_; map $i.$".$_, @ans } @{pop()} while @_; \@ans; } my @colors = qw(red green blue); my @directions = qw(north south east west); my @numbers = (1..3); my $array = glob_array( \@colors, \@directions, \@numbers ); use Data::Dump 'pp'; pp $array;
|
|---|