#! /usr/bin/perl use strict ; use warnings ; # $|++ ; while ( ) { /^Phys.*(\w)-(\w\w)-(\w\w)$/ ; my $match = 'hhh' . $1 . $2 . $3 . 'kk' ; print "The new string is: $match\n" ; last ; } __DATA__ Physical Address. . . . . . . . . : 00-B0-D0-87-52-19 DHCP Enabled. . . . . . . . . . . : No IP Address. . . . . . . . . . . . : 192.45.10.166