http://www.perlmonks.org?node_id=989617


in reply to Re^4: Retain first 4 characters of a string
in thread Retain first 4 characters of a string

$ perl -Mstrict -Mwarnings -E ' > open my $inFH, q{<}, \ <<EOF or die $!; > baby blue > baby pink > black > dark blue > brown > dark purple > green > orange > hot pink > light purple > red > white > yellow > light powder blue > EOF > > say for > map { > @$_ > 1 > ? join q{}, map { substr $_, 0, 1 } @$_ > : $_->[ 0 ] > } > map { [ split ] } > <$inFH>;' bb bp black db brown dp green orange hp lp red white yellow lpb

Cheers,

JohnGG