'How to lcfirst each group of words?

Why this is not working as I expected?

$ echo 'JOHN, BO PEEP, BoPeep' | perl -0777ne 'map { print ($_) if $_ ne uc($_) } split /,/'
 BoPeep

$ echo 'JOHN, BO PEEP, BoPeep' | perl -0777ne 'map { print lcfirst($_) if $_ ne uc($_) } split /,/'
 BoPeep

The only difference between the two commands is print ($_) vs print lcfirst($_), while I was expecting that print lcfirst($_) would output boPeep instead.

What am I missing?

Sample input:

JOHN, BO PEEP, BoPeep, AVG, Hex_String_Literal, Time_String, MODULE



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source