while (my $words = ) { chomp $words; push @matches, $words if $words =~ /a$/ } #### my @matches = grep { chomp; /a$/ } ;