#! 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 #### 22:59 >perl 1500_SoPW.pl [ ["Jakarta", "paris", "delhi", "singapore"], ["hot", "cold", "wet"], ["yes", "no", "cannotcomment"], ["black", "white"], ] Jakarta, hot, yes, black Jakarta, hot, yes, white Jakarta, hot, no, black Jakarta, hot, no, white Jakarta, hot, cannotcomment, black Jakarta, hot, cannotcomment, white Jakarta, cold, yes, black Jakarta, cold, yes, white Jakarta, cold, no, black Jakarta, cold, no, white Jakarta, cold, cannotcomment, black Jakarta, cold, cannotcomment, white Jakarta, wet, yes, black Jakarta, wet, yes, white Jakarta, wet, no, black Jakarta, wet, no, white Jakarta, wet, cannotcomment, black Jakarta, wet, cannotcomment, white paris, hot, yes, black paris, hot, yes, white paris, hot, no, black paris, hot, no, white paris, hot, cannotcomment, black paris, hot, cannotcomment, white paris, cold, yes, black paris, cold, yes, white paris, cold, no, black paris, cold, no, white paris, cold, cannotcomment, black paris, cold, cannotcomment, white paris, wet, yes, black paris, wet, yes, white paris, wet, no, black paris, wet, no, white paris, wet, cannotcomment, black paris, wet, cannotcomment, white delhi, hot, yes, black delhi, hot, yes, white delhi, hot, no, black delhi, hot, no, white delhi, hot, cannotcomment, black delhi, hot, cannotcomment, white delhi, cold, yes, black delhi, cold, yes, white delhi, cold, no, black delhi, cold, no, white delhi, cold, cannotcomment, black delhi, cold, cannotcomment, white delhi, wet, yes, black delhi, wet, yes, white delhi, wet, no, black delhi, wet, no, white delhi, wet, cannotcomment, black delhi, wet, cannotcomment, white singapore, hot, yes, black singapore, hot, yes, white singapore, hot, no, black singapore, hot, no, white singapore, hot, cannotcomment, black singapore, hot, cannotcomment, white singapore, cold, yes, black singapore, cold, yes, white singapore, cold, no, black singapore, cold, no, white singapore, cold, cannotcomment, black singapore, cold, cannotcomment, white singapore, wet, yes, black singapore, wet, yes, white singapore, wet, no, black singapore, wet, no, white singapore, wet, cannotcomment, black singapore, wet, cannotcomment, white 23:00 >