TXT FILE (testcase) option1:apple,banana,orange option2:apple,banana,orange option3:pork,chicken,beef #location and name of txtfile my $testcase="/home/jay/testcase/" my @a= &getValues($testcase,"option1"); my @b= &getValues($testcase,"option2"); my @c= &getValues($testcase,"option3"); foreach $ao(@a) { foreach $bo(@b) { foreach $co(@c) { print "$ao$bo$co; } } } sub getValues() { # accept parameter local ($keyword) = $_[1]; local ($mytestcases) = $_[0]; # retrieve txtfile testcases rows open (TESTCASE, $mytestcases) || die "couldn't open the file!\n"; @raw_value = ; close(TESTCASE); # locate keyword foreach $rowsxx (@raw_value) { # split row item to get keyword @row_values = split(":",$rowsxx); #print "@row_values[0]\n"; # checking of keyword [use eq to compare string] if ($keyword eq @row_values[0]) { # split @row_values[1] to get config values @config_values = split(",",@row_values[1]); return @config_values; last; } } }