$_ = q(5 <$> const(PV "{key}") s ->6\n); /^(.*?<.> )([\w-]+|\S+)(.*?)$/ or next # $1 == 19 # $2 eq "const" # $3 eq '(PV "{key}") s ->6\n' # Matching against $3 my $pv = ( $3 =~ /[INP]V ("?(?:\\"|[^"])*"?)/ )[0]; # Or matching against a variable and then assigning into it. my $pv = $3; $pv = ( $pv =~ /[INP]V ("?(?:\\"|[^"])*"?)/ )[0];