#!/usr/bin/perl -wl use strict; my $foo="xoxoxoxoxoxoxoxoxoxoxoxoxoxoxox"; $foo=~s/^(.)(.+?)(.)$/\U$1\E\L$2\E\U$3\E/; print $foo;