http://www.perlmonks.org?node_id=1015890


in reply to Clubbing array elements together:

What's wrong with a foreach approach?
$ perl -Mstrict -MData::Dumper -e ' my @words=("",",","abcd","efgh","","","jklm","nopq",""); my $combined; my @combinations; for my $word (@words){ if ($word){ $combined .=$word; } else{ push @combinations, $combined if $combined; $combined=""; } } @words=@combinations; print Dumper\@words;' $VAR1 = [ ',abcdefgh', 'jklmnopq' ];
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."