in reply to Pattern Match n00b
Doesn't the ;?? mean match semi-colon 0 or 1 times and be non-greedy?
Yes, it does, but that's not what you want. You need the .+ to be non-greedy or else disallow semi-colons in your values:
To make the matching more robust, you'll want to do something like this:@{$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)/;
|
|---|