I am trying to split a string into an array with the split occurring in white spaces. Each block of text is divided by numerous (variable) spaces.
Here is the line:
NUM8 host01 1,099,849,993 1,099,849,992 1
I tried the following without success.
my @array1 = split / /, $VAR1; my @array1 = split / +/, $VAR1; my @array1 = split /\s/, $VAR1; my @array1 = split /\s+/, $VAR1;
I would like to end up with:
$array1[0] = NUM8 $array1[1] = host01 $array1[2] = 1,099,849,993 $array1[3] = 1,099,849,992 $array1[4] = 1
What is the best way to share this?
Thanks!
split perl
hallert
source share