You can split on whitespace OR hyphen by using alternation within the split regexp:
my @id = split /-|\s/, $ident;
The above code would solve the problem illustrated in the text of your question. Notice: I used \s to indicate "space". \s is not strictly synonomous with "space", as it also matches tab, newline, etc. You could use the actual space character in your split regex. I used \s to make it easy to read the regex.
The subject of your question, "Splitting Arrays" doesn't match the text of your question. Is there something you left out? We're not splitting arrays here, we're splitting strings into an array.
Dave
"If I had my life to live over again, I'd be a plumber." -- Albert Einstein
|