my $word = "color: "; my $lineno = 0; while () { $lineno++; if (m#$word(\w+)#) { # $1 should now contain the color } } #### if (m#$word(\w+)#o) {