[tpm] Dealing with nested map { grep {} }

Tom Legrady legrady at gmail.com
Tue Sep 26 14:57:24 PDT 2017


I was worried your solution wouldn't work with Const::Fast, but it does ...

perl -MData::Dumper -MConst::Fast -le 'const my @ar => qw/a b c d e f 
g/; $hash{$ar[$_]} = [ @ar[0 .. $_ - 1, $_ + 1 .. $#ar] ] for 0 .. $#ar; 
print Dumper \%hash'
$VAR1 = {
           'e' => [
                    'a',
                    'b',
                    'c',
                    'd',
                    'f',
                    'g'
                  ],
           'a' => [
                    'b',
                    'c',
                    'd',
                    'e',
                    'f',
                    'g'
                  ],
      .......

        };



On 2017-09-26 05:28 PM, Viktor Pavlenko wrote:
> perl -MData::Dumper -le '@ar = qw/a b c d e f g/; $hash{$ar[$_]} = [ @ar[0 .. $_ - 1, $_ + 1 .. $#ar] ] for 0 .. $#ar; print Dumper \%hash'


More information about the toronto-pm mailing list