I have an array where the elements look like this (whitespaces included)
@array = (
" 795 0| 1",
" 5 135| 17",
" 12 161| 17",
" 244 22| 17",
" 11 25| 17",
" 249 389| 17",
" 22383 443| 17"
);
I need to take an element out
" 795 0| 1"
and split it into 3 numbers getting rid of the white spaces and “|” in each line.
@new_array =("795","0","1");
The problem I’m having is that the whitespace and size of the numbers varies.
I would use a regexp matching only the numbers:
This will also work if the string has no whitespace in the beginning.