#!/usr/bin/perl -wT use strict; my @characters = ( [ "h" ], [ "e" ], [ "l", "p", "i" ], [ "l" ], [ "o" ], ); my @words = glob('{'.join("}{",map{join',',@$_}@characters).'}'); print "The possible words are:\n"; print " $_\n" for @words; __END__ The possible words are: hello heplo heilo