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

echo 'authentication' | perl -F'' -lape '$_ = $F[0] . (@F-2) . $F[-1]'
Modified: added -a as advised by choroba
And like that ... he's gone. -- Verbal

Replies are listed 'Best First'.
Re: Terms shortener :-)
by choroba (Bishop) on Jan 09, 2018 at 13:29 UTC
    For pre-5.20 perls, one needs -alpe , as a ins't implied by F .

    I'd also try

    perl -pe 's/.\K(.*)(?=.)/length$1/e'
    (needs 5.10).

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      Or even

      perl -pe 's/(?<=.)(.*)(?=.)/length$1/e'