#THIS LINE BELOW! if ( $contents =~ /^line2-(\w*)/mo ) { print $1; # has to be changed as well } }