$ perl -wle' $_ = "text"; m/(t)/; print "\$1: ($1)"; m/(T)/; print "\$1: ($1)";' $1: (t) $1: (t) $