DEV Community

loading...

Discussion on: Perl Weekly Challenge #1: translate letters and count.

Collapse
learnbyexample profile image
Sundeep

Here's Perl5 one-liner

$ echo 'Perl Weekly Challenge' | perl -lne '$c = s/e/E/g; print "$_\n$c"'
PErl WEEkly ChallEngE
5

$ # shorter if count has to be displayed first
$ echo 'Perl Weekly Challenge' | perl -lpe '$c = s/e/E/g; print $c'
5
PErl WEEkly ChallEngE