#The regex, commented for your convinence. $Error =~ /Sequence\s #opening anchor, don't capture ( # open capturing group to get target pattern .+? # target pattern, non-greedy catch all ) # close group \sconsists # closing anchor, don't capture /x; # end regex #### ($Missing_Living_Being) = $Error =~ /Sequence\s(.+?)consists/;