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


in reply to Retain first 4 characters of a string

perlnoobster,

I just added flavors to your dish so that it is eatable and delicious!

$phn = "Apple iPhone 4 Black Cover"; print $trim = join '-', (map { substr($_, 0, 4) } split /\s+/, $phn);