if ( $work =~ /(For #DON'T KNOW WHAT TO PUT HERE )/ ) { $instruments = $1; $instruments =~ s/[()]//g; #remove extra parentheses $work =~ s/$instruments//g; #remove instruments $instruments =~ s/^\s+//; #remove leading spaces $instruments = substr($instruments, 4, 100); #last line removes the substring "For " }