First of all, what do you mean by null? I will assume you mean undef, but you might as well mean the numerical value 0.

Secondly, one of Perl's slogan's is There Is More Than One Way To Do It, or TIMTOWTDI as we say. This applies here as well. There is no the correct way, there are many.

My next question, thus, is: what have you tried? Why didn't it work? Did you get any error messages and if you did, which? How did your output not meet your expectations?

Lastly, a regular expression in the traditional sense (m//) might not b the most suitable task. What you have is a | delimited string, so most likely you'll want to split on that. Keep in mind that split takes a regular expression as its first argument, and | has a special meaning inside regular expression so you'll have to escape that.

Then you'll want to iterate over the list you get, using something like map for example, or if you're uncomfortable with those merits of functional programming, you could do it with a simple foreach loop over the array.