# Build a hash of word counts foreach ( map @$_, @all ) { $words{$_} ++ } # Create a list of arrays showing repeats @out = map { [ map $words{$_} > 1 ? 1 : 0, @$_ ] } @all; #### # List processing with foreach/push foreach ( @input ) { push @out, lc($_); } print @out; # Equivalent "rolled-up" map expression: print map { lc($_) } @input;