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


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

Its even simpler than that , append

say "BUT YOU CAN USE LESS OF THEM :) OR LEARN FROM s/// "; $trim = join '-', $orig =~ m{(\w{1,4})\w*}g; say Dumper $want, $trim ;

and get extra output

BUT YOU CAN USE LESS OF THEM :) OR LEARN FROM s/// $want = 'Appl-iPho-4-Blac-Cove'; $trim = 'Appl-iPho-4-Blac-Cove';