http://qs321.pair.com?node_id=1221104

lunix has asked for the wisdom of the Perl Monks concerning the following question:

Hi all

The task is the following: We have an array of words for example ["anyone", "cancel", "declare", "perlmonks"]. We need to print the word, if it contains an "a" and also the number of "e"-s in that word. The syntax has to be: "word: number". Easy, right? Here is a perl program that does this and is very easy to understand:
#!/usr/bin/perl -w use strict; my @words = ("anyone", "cancel", "declare", "perlmonks"); my $count = 0; foreach (@words) { if ($words[$count] =~ m/a/i) { my $number = () = $words[$count] =~ /e/gi; print "$words[$count]: $number\n"; } $count ++; }

This outputs:
anyone: 1 cancel: 1 declare: 2

Just for fun, I am searching for the shortest perl one-liner that does the same. This is the shortest version I could come up with, with my current knowledge of perl:
perl -e 'for('anyone','cancel','declare','perlmonks'){$i=()=/e/g;print +"$_: $i\n"if(/a/);}'

I was wondering what kind of magic solution the great minds here could come up with. Feel free to impress me! :)

Update: Current shortest version is

perl -E'/a/&&say"$_: ".y/e//for anyone,cancel,declare,perlmonks'