@{$pets} = $1 if $pet_list =~ /$some_variable\:(.*?)(;|\z)/; # or not allow ';' in values: @{$pets} = $1 if $pet_list =~ /$some_variable\:([^;]*)(;|\z)/; #### @{$pets} = $1 if $pet_list =~ /(?:\A|;)\Q$some_variable\E\:([^;]*)(;|\z)/;