#! perl use strict; use warnings; use Algorithm::Loops qw( NestedLoops ); use Data::Dump; my @AoA; while () { chomp; my @fields = split; push @AoA, \@fields; } dd \@AoA; NestedLoops ( [ @AoA[0 .. $#AoA] ], sub { print join(', ', @_), "\n"; }, ); __DATA__ Jakarta paris delhi singapore hot cold wet yes no cannotcomment black white