use strict; use warnings; my @array = qw(toad frog frig frag crow creep hop); my @sorted; for (@array) { if ( $_ =~ m/.*r/g ) { push( @sorted, $_ ); } } print "$_\n" for sort(@sorted); #### creep crow frag frig frog